Question

i need to add a custom path to refinerycms project, here is how i did it:

mount Refinery::Core::Engine, :at => '/'
get 'news/more' => 'refinery::news::items#view_more', as: :news_view_more

now 'rake routes' can prints correct routes, but i can't refer to that path by refinery.news_view_more_path, however i found some code like ’refinery.news_item_path‘ in refinerycms gem source code, i want my custom routes can be refered that way.

thanks !

Was it helpful?

Solution

@manosagent, i can add routes like that:

Refinery::Core::Engine.routes.prepend do
  get 'news/more' => 'news::items#view_more', as: :news_view_more
  get 'notices/more' => 'notices::notices#view_more', as: :notices_view_more
end

but i don't understand why new/more appears twice in rake routes, i need to dig deeper ...

OTHER TIPS

I believe since your routing is not RESTFUL you will not be able to use helpers to get the paths you want. You should either use RESTFUL routing or create a helper for your needs.

I have spent some time to figure it out. If you are using separate controller in your rails app, then you can put your routes code on top of the routes. Remember that routes wont work on refinery page view/refinery/*.*. If you want to add some custom routes on refinery page like view/refinery/*.* then you can follow below code.

Refinery::Core::Engine.routes.draw do
  devise_for :users
  get 'author' => 'author#index'
end

on your routes file.

Refinery CMS deeply hacked its routes, there are plenty patches from "refinery gems", so that all the urls will be filtered by Refinery's Core Action(such as Refinery::PagesController#show )

Actually I don't have time to dive in, all above is my guess...

So if you want to add a new route, just add non-RESTful route there, e.g.:

get 'news/more' => 'refinery::news::items#view_more', as: :news_view_more

put this line before refinery's other routes, will work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top