SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ** Please Help! ** - unable to save to the database

    Hello,

    I am following the RailsSpace tutorial and am at the point where I am
    creating a new user through (user/register)

    I have added the details into the form: screen_name, email and
    password.

    When I click register, I would expect this to be saved (commited) to
    the database.

    However – when I look in the terminal, it says ‘Rollback’ instead of
    ‘COMMIT’


    the code in the user controller looks like this:


    class UserController < ApplicationController


    def register
    @title = "Register"
    if request.post? and params[:user]
    @user = User.new(params[:user])
    if @user.save
    flash[:notice] = "User #{@user.screen_name} created!"
    redirect_to :action => "index"
    end
    end
    end


    Does anyone know why in my terminal it is not saving this as I’d
    expect?

    NB - this code is taken straight from the book. (the book refers to version 1.2.3, and i'm using 1.8.7 but i doubt this is the issue in this case....


    Many Thanks

  2. #2
    SitePoint Zealot phillipus_rex's Avatar
    Join Date
    Jan 2007
    Location
    Silicon Holler
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code looks fine... it should work provided that you have a User model set up and you have created your database.

    Have you tried rebooting the server?
    "Be kind, for everyone you meet is fighting a
    hard battle." -Plato


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •