Form trying to save null values?

Ryan Bentz
Thu, 22 Feb 2007 16:47:13 -0000

Hey there...new to the group but looks like there''s some great
discussion
going on throughout!

I''m working on a sign up form right now that takes just an email and
zip
code. It appears that the email and zip code make it as far as the SELECT
statements when attempting to save the new user, but when it tries to save
said values to their respective columns in the DB the log shows VALUES(null,
null). My code looks like this:

profile controller:
def rSignIn
    @retailUser = RetailUser.new(params[:user])
    if request.post?
      if @retailUser.save
        session[:user] = RetailUser.authenticate(@retailUser.email, @
retailUser.location)
        flash[:message] = "Signup successful"
        redirect_to :controller => "browse", :action =>
"retailHome"
      else
        flash[:warning] = "Signup failed"
      end
    end
  end

retail user model:
validates_length_of :email, :within => 6..65
  validates_length_of :location, :is => 5
  validates_presence_of :email, :location
  validates_uniqueness_of :email
  validates_format_of :email, :with =>
/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :message => "Invalid
email"

  attr_protected :id

  attr_accessor :email, :location

  def self.authenticate(email, location)
    u = find(:first, :conditions => ["user[email]=?",email])
    return nil if u.nil?
    return u
    nil
  end

sign in view:
<% form_for :user, @retailUser, :html => {:id =>
"retailSignInForm"}, :url
=> { :controller => "profile", :action =>
"rSignIn"} do |f| %>

Email:
<%f.text_field:email, :id => "retailSignInText", :class=>
"text" %>


Zip code:
<%f.text_field:location, :id => "retailSignInZip", :class=>
"text" %>


            <%= button_to "Sign In", :controller =>
"profile", :action =>
"rSignIn" %>

    <% end %>

Any clue as to what I''m doing wrong?