Search code examples
ruby-on-rails-3routesrestful-architecture

Rails -- reroute only one of the resource routes


I have a resource called Entries, which has all the normal default RESTful routes that go along with a resource. I want to leave all the routes as they are EXCEPT I want the show action to be rerouted to my Articles controller (Articles#show). Here is my current (but not working) code in my routes file:

resources :entries do
    member do
      get 'entry' => 'articles#show'
    end
  end

Any ideas on how to solve this problem? I want to leave all the other routes from the Entries resource exactly as they are.


Solution

  • I think you should add a match before the resource articles. If I understand, you want the route /entries/1/entry to go to the articles show? Else just change the match line with what you want.

    match "entries/:id/entry" => "articles#show"
    
    resources :articles
    resources :entries