Hello. I switched to rails and mac from c# and a pc. I''m lovin it, but
wierd things keep happening with my code and after 3 days I am totally
stuck.
I have a form in login.rhtml
<%= form_tag :action => ''process_registration'' %>
<h3>Register</h3>
<p>Email Address:<br><%= text_field "user",
"email_address", :id
=> ''stext'' %><br>
Password:<br><%= password_field "user",
"password", :id =>
''stext'' %><br>
Confirm Password:<br><%= password_field "user",
"confirm_password", :id => ''stext''
%><br>
<br>
<span style="margin: 16px;"><%= submit_tag
''register'' %></span>
</p>
<%= end_form_tag %>
this goes to my controller code:
def process_registration
@user = User.new(params[:user])
@user.save
return
end
my migration for the table:
def self.up
create_table :users do |t|
t.column :first_name, :string, :limit => 32
t.column :last_name, :string, :limit => 32
t.column :email_address, :string, :limit => 128, :null => false
t.column :password, :string, :limit => 32, :null => false
end
end
I can manually insert into the table, I can also circumvent my form and
just do a
@u = User.new
@u.email_address = "blah-7Ts6kVb0ZJk@public.gmane.org"
@u.password = "something"
@u.save
that adds a row. if I use User.new(params[:user]) or even
@u.email_address = params[:user][:email_address] then I get nulls in the
database.
I am going insane! I have migrated down and back up, removed all
validation from my model:
class User < ActiveRecord::Base
attr_accessor :password, :email_address
attr_accessor :confirm_password
def self.authenticate( user )
find( :first, :conditions => [ "email_address = ? and password =
?",
user[:email_address], user[:password] ] )
end
end
i have redone my form over and over, the code goes from the form to the
controller, calls the right method, etc. if I use the debugger I can see
my value in the params[:user][:password] but when save is called it only
inserts nulls.
Am I missing something really stupid?
Please help, my client is getting pissed :)
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---