943,677 Members | Top Members by Rank

Ad:
  • Ruby Discussion Thread
  • Marked Solved
  • Views: 2084
  • Ruby RSS
Dec 31st, 2008
0

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

Expand Post »
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:

Ruby Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
clem_c_rock is offline Offline
7 posts
since Aug 2005
Jan 8th, 2009
0

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

In your controller do you have

ruby Syntax (Toggle Plain Text)
  1. @user = User.find(:first)

or something similar? Could you post your controller code?
pty
Reputation Points: 64
Solved Threads: 39
Posting Pro
pty is offline Offline
530 posts
since Oct 2005
Jan 10th, 2009
0

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

Problem solved: all I had to do was to add Address.new in the controller.

Newbies
Reputation Points: 10
Solved Threads: 0
Newbie Poster
clem_c_rock is offline Offline
7 posts
since Aug 2005

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Ruby Forum Timeline: Need help to install rails on Ubuntu
Next Thread in Ruby Forum Timeline: HABTM Question w/ checkboxes





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC