I'm judging from your response that you would you argue that using a
Rails view helper inside another view helper is wrong then? I would
say this isn't crazy its just trying to DRY up a small form (just a
button) I am using in lots of different places.
I found the solution in the end.
module MyHelper
def button_thing_attempt_2
with_output_buffer(form_for(Button.new) do |f|
concat(f.submit 'Push')
end)
end
end
RobL
On 27 November 2010 03:16, daze <dmonopoly10@gmail.com> wrote:
> Whoa whoa whoa. form_for is for the VIEW. It generates html.
> Specifcally, it generates <form> tags and etc...
>
>
> On Nov 26, 2:35 pm, RobL <pgdst...@gmail.com> wrote:
>> Hi there,
>>
>> I'm having an awful lot of trouble trying to use form_for inside a
>> helper. Any ideas how to get this to work?
>>
>> module MyHelper
>>
>> def button_thing_attempt_1
>> form_for(Button.new) do |f|
>> f.submit 'Push'
>> end
>> end
>>
>> def button_thing_attempt_2
>> with_output_buffer(form_for(Button.new) do |f|
>> f.submit 'Push'
>> end)
>> end
>>
>> end
>>
>> While I get attempt 2 to render the form, the submit button is
>> missing. I'm just not quite sure how to really capture the complete
>> output of form_for.
>>
>> Many thanks for any help here
>>
>> RobL
>
> --
> 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@googlegroups.com.
> 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.
>
>
--
Rob Lacey
contact@robl.me
http://www.robl.me
--
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@googlegroups.com.
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.
No comments:
Post a Comment