Luiz Vitor Martinez Cardoso
2008-Jul-29 03:57 UTC
Passing strings from model to a form, to edit the information
Yeah, 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 %> But what''s object really does? -- Regards, Luiz Vitor Martinez Cardoso cel.: (11) 8187-8662 blog: rubz.org engineer student at maua.br --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thorsten Müller
2008-Jul-29 09:02 UTC
Re: Passing strings from model to a form, to edit the information
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 --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---