Named routes in Alchemy modules

49 views
Skip to first unread message

Jesper Petersson

unread,
Feb 20, 2013, 3:27:48 AM2/20/13
to alche...@googlegroups.com
Hi!

I've got some problems with named routes in the Alchemy CMS. I was hoping that you guys maybe know why it's happening and what I can do about it.

I created an Alchemy module named products. In the toolbar view of the module I would like to use named routes to link to products#new. The view is calling `new_admin_product_path` but I receive the following error message:
Error: undefined local variable or method `new_admin_product_path' for #<#<Class:0x007fd670192258>:0x007fd67062d808>

However, when I run `rake routes` it gives the route just as expected:
new_admin_product GET /admin/products/new(.:format) admin/products#new

My config/routes.rb: http://pastebin.com/sftSMr3A

Are there anyone else that have encountered the same problem? Any clues of how to resolve it?

Thanks in advance,

/Jesper

Thomas von Deyen

unread,
Feb 20, 2013, 3:31:45 AM2/20/13
to alche...@googlegroups.com
Yes,

this is a common Rails engines "problem". Sadly, this is poorly documented.

In order to make routes work in the Alchemy engine, you have to call all your apps routes with `main_app.name_of_the_route`

So in your example:

`main_app.new_admin_product_path`

Hope this helps.

Best 
Thomas

--
You received this message because you are subscribed to the Google Groups "Alchemy CMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to alchemy-cms...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jesper Petersson

unread,
Feb 20, 2013, 3:36:14 AM2/20/13
to alche...@googlegroups.com
Ah, sweet! It works perfectly.

Thanks!

/Jesper
Reply all
Reply to author
Forward
0 new messages