rubyonrailsin

A Ruby and Rails talk

Wednesday, March 31, 2010


[spree-user] Re: undefined method link_to in extension hooks file

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

Answer to my own question. Stuff in hooks should be text, which will
later be parsed as erb in the view:

insert_after(:admin_configurations_menu) do
'<tr>
<td><%= link_to t("rent_a_cop_management_link"), "/" %></td>
<td><%= t("rent_a_cop_description") %></td>
</tr>'
end

On Mar 31, 1:30 pm, lesfreeman <lesliefreem...@gmail.com> wrote:
> In my extension hooks file I am trying to add a link to the config
> menu:
>
> class RentACopHooks < Spree::ThemeSupport::HookListener
>
>   insert_after :admin_configurations_menu do
>     '<tr><td>'+link_to(I18n.t("rent_a_cop_management_link"), '/')+'</
> td><td>'+I18n.t("rent_a_cop_description")+'</td></tr>'
>   end
>
> end
>
> It works fine if I take out the link_to and just put in normal text,
> but with the link_to I get an undefined method error.
>
> I tried adding an include ActionView::Helpers::UrlHelper to no avail.
>
> The example code shows:
> insert_after :product_description do
>      '<p>' + link_to('Back to products', products_path) + '</p>'
>     end
>
> Which, when I uncomment it and go to the products page, gives an
> undefined method error for products_path.
>
> What am I missing?
>
> Thanks
> Les

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To post to this group, send email to spree-user@googlegroups.com.
To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive