I am trying to get this to work: def do_button(event_type) varname = event_type.name.underscore humanname = event_type.new.event_name_string form_for (@user, :url => "do_#{varname}_user_path(@user)") do | form| submit_tag "I got my #{humanname} today" end end My view has this in it: <li> <% do_button(Mammogram) %> </li> But I keep getting this error in the log from the form_for line inside the helper: ActionView::TemplateError (undefined local variable or method `_erbout'' for <ActionView::Base:0x357355c>) in users/ _mammogram.html.erb. Can''t figure out what to do. Anyone? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
form_for does not work in a helper. Use a partial instead. Aaron --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ramhoj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Feb-18 16:52 UTC
Re: Embedding a full form in a helper
Hi. I have the same problem... As I''m still trying to find whats wrong I can only share some guesses: 1. The error is the same as when you do something like this in the view: <%= form_for(@user) do |f| %> (note the ''='') So my guess is that what happens is that the block treats all the code as it was inside <%= %>-tags and therefore breaking the "sub-block"... Please let me know if you find a solution to the problem... Thanks, Nicklas On Jan 23, 5:07 pm, Pito <pitosa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am trying to get this to work: > > def do_button(event_type) > varname = event_type.name.underscore > humanname = event_type.new.event_name_string > form_for (@user, :url => "do_#{varname}_user_path(@user)") do | > form| > submit_tag "I got my #{humanname} today" > end > end > > My view has this in it: > > <li> > <% do_button(Mammogram) %> > </li> > > But I keep getting this error in the log from the form_for line inside > the helper: > > ActionView::TemplateError (undefined local variable or method > `_erbout'' for <ActionView::Base:0x357355c>) in users/ > _mammogram.html.erb. > > Can''t figure out what to do. Anyone?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---