I have the following: <% form_for @user do |f| -%> ... <%= render :partial => "relationship_status" %> ... <% end -%> How do I pass f to the partial! :-) Or can I not do that? -- John Kopanas john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org Blog: http://www.kopanas.com Conference: http://www.cusec.net Twits: http://www.twitter.com/kopanas --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Feb 9, 8:03 am, "John Kopanas" <kopa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have the following: > > <% form_for @user do |f| -%> > ... > <%= render :partial => "relationship_status" %> > ... > <% end -%> > > How do I pass f to the partial! :-) Or can I not do that?Just pass the form to the partial as a ''local'' like this: <%= render :partial => "relationship_status" %, :locals => {:form => f } %> You can then refer to the form in your partial like this: <%= form.text_field ... %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Are you sure that you need to? If you are rendering relationship info for the user, but that relationship info relies on some other model, you might be able to: _relationship_status.html.erb <% fields_for :relationships, relationships do |fld| %> <% fld.text_field ... %> <% end %> and pass the user into the partial: <%render :partial=>''relationship_status'', :locals=>{:relationships=>user.relationships} %> The main point being that if you''re rendering a partial that displays fields for a different model then you don''t need to pass the form variable, but a reference to that model or collection. On Feb 9, 11:43 am, bigbanger <bigbanger...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Feb 9, 8:03 am, "John Kopanas" <kopa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I have the following: > > > <% form_for @user do |f| -%> > > ... > > <%= render :partial => "relationship_status" %> > > ... > > <% end -%> > > > How do I pass f to the partial! :-) Or can I not do that? > > Just pass the form to the partial as a ''local'' like this: > > <%= render :partial => "relationship_status" %, :locals => {:form => > f } %> > > You can then refer to the form in your partial like this: > > <%= form.text_field ... %>--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---