I’m trying to develop a “User Profile” and want to show some forms with the content stored in database. I search in documentation but i don’t find anything useful. I try
at controller:
@u = User.find(:last)
at view:
<% form_for :user |f| do %>
f.text_field :name, :object => @u.name
<% end %>
Don't know, what you're doing here. You should use:
@user = User.find(:last)
Then:
<% form_for :user |f| do %>
f.text_field :name
<% end %>
Is all you need. If you use form_for :user, then
Rails expects the data to be in object @user and
if you use f.text_field instead of the simple text_field,
then Rails knows already, that the object to be used
is that bound to the form (@user in htis case) and
knows, that :name is @user.name