Forum: Ruby on Rails Clearing form fields for a popup

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F677fa685a2cfe8aff31f161062db3d3?d=identicon&s=25 David (Guest)
on 2008-11-26 04:01
(Received via mailing list)
I am using prototype to create modal popups for my login and register
pages, but the fields are populating with the data from certain
variables.  For example, I have a show page that finds a user like
so:

@user = User.find(params[:id])

and my form uses:
<% form_for :user, :url => users_path do |f| -%>

so it is populating the form with the data from @user.  Should I
rename the @user variable, or is there a way to avoid the populating
of the form?

Thanks for any help.
2b891e820c238ded365d035771603f21?d=identicon&s=25 Bill Walton (Guest)
on 2008-11-26 15:13
(Received via mailing list)
Hi David,

David wrote:
>
> so it is populating the form with the data from @user.  Should I
> rename the @user variable, or is there a way to avoid the populating
> of the form?

You should be doing the find in the controller and calling the new
method to
return a new, empty object or the edit method to return an existing
object.

HTH,
Bill
This topic is locked and can not be replied to.