Hi all,
I have a query about how to access helper methods in a library. I''m
trying to create a custom liquid drop thing which has a form in it (a
poll), and I''m unable to get form_for to work with
"vote_poll_path".
Here''s my code for the custom drop (this is in a file in lib):
def render(context)
@vote = Vote.new(:poll_id => @poll.id)
output = "<div class=''poll''><a
href=''/polls/#{@poll.id}''>#
{@poll.question}</a>"
output += context.capture(form_for @vote, :url =>
context.vote_poll_path(@vote.poll))
for choice in @poll.choices
output += "<input type=''radio''
name=''choice_id'''' value=''#
{choice.id}''>#{choice.description}</input>"
end
output += "</div>"
output += "<input type=''submit''
value=''Vote!'' />"
output += "<% end %>"
end
And here''s the error I get:
Liquid error: undefined method `vote_poll_path’ for #
I''ve watched Railscast episode 132 (helpers outside views) for some
information on how to do this but I''m still stuck. At the end he
mentions @template but I can''t get that to work either, it gets
evaluated as nil. I''d be really grateful for any help.
Thanks,
Mark
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---