I can''t possible tell you how to do that, whatever you''re
doing (which
is, btw, vry unclear)
here''s what you do, open YourControllerNameHelper.rb in the helpers
folder
module YourControllerNameHelper.rb
def do_menu_bar
#do processing
return "text to render"
end
end
then you use
<%= do_menu_bar %>
Don''t ever eval code in the view... just don''t. Why would you
want to
do that anyway?
On Jul 30, 7:04 am, Axel Bock
<mr.Axel.B...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
>
> I am quite new to rails and ruby, and I have a little issue here: I
> want to write a helper method which generates some erb code, which I
> want to call and then eval from a template.
>
> This is best illustrated with an example. I want a menu bar on a page
> like this:
>
> --- in the erb template: ---
> <%
> rails_code = do_menu_bar_with([:back, :delete, :comment])
> %>
> <%= eval(rails_code) %>
> --- end ---
>
> I know this is probably not working, a shitty approach and generally
> flawed, but that''s basically what I need.
>
> So now I have two questions, and I am happy for any answer :-) :
>
> 1. Where would I put this method "do_menu_bar_..."? it surely
does not
> work in ApplicationController.
>
> 2. If this method returns erb code, how do I evaluate this after?
> Surely not with eval, I guess ...
>
> Thanks in advance & greetings,
> Axel.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---