1

I have a class, DynamicPage, and a subclass, ContentPage. Dynamic Pages have a content_page attribute to distinguish them.

I have 2 wildcard routes set up as follows:

resources :dynamic_pages, path: '', param: :dynamic_page_id
get "*dynamic_page_id/trackback", to: "dynamic_pages#show"
get "*dynamic_page_id", to: "dynamic_pages#show"

and

resources :content_pages, path: '', param: :content_page_id
get "*content_page_id/trackback", to: "content_pages#show"
get "*content_page_id", to: "content_pages#show"

These routes lead to the relevant controller depending on which route I place first . Let us assume the dynamic page being shown is called dp. What I want to do is change the route depending on whether dp.content_page is true or not. Is this possible in the routes? Or would I need to redirect in one of the controllers?

Thanks.

Mark
  • 6,112
  • 4
  • 21
  • 46
  • Refer to this question: http://stackoverflow.com/questions/11230130/rails-routes-based-on-condition – MurifoX Feb 09 '17 at 16:26

0 Answers0