Forms fields pre-populating w/ first record's values

Thread Solved

Join Date: Aug 2005
Posts: 7
Reputation: clem_c_rock is an unknown quantity at this point 
Solved Threads: 0
clem_c_rock clem_c_rock is offline Offline
Newbie Poster

Forms fields pre-populating w/ first record's values

 
0
  #1
Dec 31st, 2008
I have a strange situation. I want to have a create_user form w/ all the fields blank

When I call the create_user method, the corresponding create_user.html.erb form is displaying the first
record's data from the user table in the form fields

Here's a quick view of my form:

  1. <% form_tag('create_user') do -%>
  2. <%=hidden_field("user", "id") %> (<%=params[:id] %>)
  3. <p><label for="fname">First Name</label><br/>
  4. <%=text_field("user", "fname") %></p>
  5.  
  6. <p><label for="lname">Last Name</label><br/>
  7. <%=text_field("user", "lname") %></p>
  8. <%=submit_tag("Create") %>
  9. <% end -%>

When that form loads, it is populated w/ the First and last name from the first user record in the db.

Anyway around this - I've tried everything I can think of.

Thanks,
Clem
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 523
Reputation: pty is on a distinguished road 
Solved Threads: 37
pty's Avatar
pty pty is offline Offline
Posting Pro

Re: Forms fields pre-populating w/ first record's values

 
0
  #2
Jan 8th, 2009
In your controller do you have

  1. @user = User.find(:first)

or something similar? Could you post your controller code?
Note to self... pocket cup
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 7
Reputation: clem_c_rock is an unknown quantity at this point 
Solved Threads: 0
clem_c_rock clem_c_rock is offline Offline
Newbie Poster

Re: Forms fields pre-populating w/ first record's values

 
0
  #3
Jan 10th, 2009
Problem solved: all I had to do was to add Address.new in the controller.

Newbies
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Ruby Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC