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 <[email protected]> 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 <[email protected]> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
Rob Lacey
[email protected]
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.