I have: <%= form_for(@supplier) do |f| %> ....... ...... <%= render ''sector_categories'', :locals => {:f => f} %> in _sector_categories partial I have: <div class="field"> <div id="category_update"> <% for category in @categories %> <%= f.check_box :category_ids[], category.id, @supplier.categories.include?(category) %> <%= category.name %><br /> <% end %> </div> </div> Why it says: undefined local variable or method "f"? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Quoting Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> I have: > <%= form_for(@supplier) do |f| %> > ....... > ...... > <%= render ''sector_categories'', :locals => {:f => f} %> > > in _sector_categories partial I have: > > <div class="field"> > <div id="category_update"> > <% for category in @categories %> > <%= f.check_box :category_ids[], category.id, > @supplier.categories.include?(category) %> > <%= category.name %><br /> > <% end %> > </div> > </div> > > Why it says: undefined local variable or method "f"? >As written, you are rendering a template, not a partial. Passing local variables to templates is not supported. Do you mean <%= render :partial => ''sector_categories'', :locals => {:f => f} %> HTH, Jeffrey -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 26 December 2010 00:35, Jeffrey L. Taylor <ror-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> wrote:> Quoting Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> I have: >> <%= form_for(@supplier) do |f| %> >> ....... >> ...... >> <%= render ''sector_categories'', :locals => {:f => f} %> >> >> in _sector_categories partial I have: >> >> <div class="field"> >> <div id="category_update"> >> <% for category in @categories %> >> <%= f.check_box :category_ids[], category.id, >> @supplier.categories.include?(category) %> >> <%= category.name %><br /> >> <% end %> >> </div> >> </div> >> >> Why it says: undefined local variable or method "f"? >> > > As written, you are rendering a template, not a partial. Passing local > variables to templates is not supported. Do you mean > > <%= render :partial => ''sector_categories'', :locals => {:f => f} %>But if I create a new application using scaffold I see a code like this: <%= render ''form'' %> and a file _form.html.rb. So it is a partial but the render command doesn''t have :partial. What''s correct? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
On 26 December 2010 00:35, Jeffrey L. Taylor <ror-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> wrote:> Quoting Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> I have: >> <%= form_for(@supplier) do |f| %> >> ....... >> ...... >> <%= render ''sector_categories'', :locals => {:f => f} %> >> >> in _sector_categories partial I have: >> >> <div class="field"> >> <div id="category_update"> >> <% for category in @categories %> >> <%= f.check_box :category_ids[], category.id, >> @supplier.categories.include?(category) %> >> <%= category.name %><br /> >> <% end %> >> </div> >> </div> >> >> Why it says: undefined local variable or method "f"? >> > > As written, you are rendering a template, not a partial. Passing local > variables to templates is not supported. Do you mean > > <%= render :partial => ''sector_categories'', :locals => {:f => f} %>As you see in http://guides.rubyonrails.org/layouts_and_rendering.html there is no need to specify :partial. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Quoting Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> On 26 December 2010 00:35, Jeffrey L. Taylor <ror-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> wrote: > > Quoting Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > >> I have: > >> <%= form_for(@supplier) do |f| %> > >> ....... > >> ...... > >> <%= render ''sector_categories'', :locals => {:f => f} %> > >> > >> in _sector_categories partial I have: > >> > >> <div class="field"> > >> <div id="category_update"> > >> <% for category in @categories %> > >> <%= f.check_box :category_ids[], category.id, > >> @supplier.categories.include?(category) %> > >> <%= category.name %><br /> > >> <% end %> > >> </div> > >> </div> > >> > >> Why it says: undefined local variable or method "f"? > >> > > > > As written, you are rendering a template, not a partial. Passing local > > variables to templates is not supported. Do you mean > > > > <%= render :partial => ''sector_categories'', :locals => {:f => f} %> > > But if I create a new application using scaffold I see a code like > this: <%= render ''form'' %> and a file _form.html.rb. > So it is a partial but the render command doesn''t have :partial. > What''s correct? >Rails 2.x or Rails 3? Jeffrey -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Quoting Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> On 26 December 2010 00:35, Jeffrey L. Taylor <ror-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> wrote: > > Quoting Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > >> I have: > >> <%= form_for(@supplier) do |f| %> > >> ....... > >> ...... > >> <%= render ''sector_categories'', :locals => {:f => f} %> > >> > >> in _sector_categories partial I have: > >> > >> <div class="field"> > >> <div id="category_update"> > >> <% for category in @categories %> > >> <%= f.check_box :category_ids[], category.id, > >> @supplier.categories.include?(category) %> > >> <%= category.name %><br /> > >> <% end %> > >> </div> > >> </div> > >> > >> Why it says: undefined local variable or method "f"? > >> > > > > As written, you are rendering a template, not a partial. Passing local > > variables to templates is not supported. Do you mean > > > > <%= render :partial => ''sector_categories'', :locals => {:f => f} %> > > As you see in http://guides.rubyonrails.org/layouts_and_rendering.html > there is no need to specify :partial. >Look again. Every example on that page with :locals, explicitly specifies :partial. Your way isn''t working. How about trying something different. The only way you will find out if the Rails 2 convention, locals only for partials, is or isn''t true in Rails 3 is trying it. You have shown that without :partial and possibly some other factor, locals don''t work. Change only one thing and run the experiment again. Jeffrey -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
On 26 December 2010 05:20, Jeffrey L. Taylor <ror-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> wrote:> Quoting Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> On 26 December 2010 00:35, Jeffrey L. Taylor <ror-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> wrote: >> > Quoting Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> >> I have: >> >> <%= form_for(@supplier) do |f| %> >> >> ....... >> >> ...... >> >> <%= render ''sector_categories'', :locals => {:f => f} %> >> >> >> >> in _sector_categories partial I have: >> >> >> >> <div class="field"> >> >> <div id="category_update"> >> >> <% for category in @categories %> >> >> <%= f.check_box :category_ids[], category.id, >> >> @supplier.categories.include?(category) %> >> >> <%= category.name %><br /> >> >> <% end %> >> >> </div> >> >> </div> >> >> >> >> Why it says: undefined local variable or method "f"? >> >> >> > >> > As written, you are rendering a template, not a partial. Passing local >> > variables to templates is not supported. Do you mean >> > >> > <%= render :partial => ''sector_categories'', :locals => {:f => f} %> >> >> As you see in http://guides.rubyonrails.org/layouts_and_rendering.html >> there is no need to specify :partial. >> > > Look again. Every example on that page with :locals, explicitly specifies > :partial. > > Your way isn''t working. How about trying something different. The only way > you will find out if the Rails 2 convention, locals only for partials, is or > isn''t true in Rails 3 is trying it. You have shown that without :partial and > possibly some other factor, locals don''t work. Change only one thing and run > the experiment again.You are right, so I''ve have notice that with rails 3 there is no need to specify :partial unless I use local variables. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.