I'm attempting to create some urls for a model that I want display. I have articles, which belong to sections which belong to issues.
I would like my URLs for the article show action to look like this:
/issue-slug/section-slug/article-slug
issues articles and sections have slugs that are stored in the db.
Right now I have a backend section called 'pressroom' and I have the following routes for that. Here is the whole routes.rb file
MaskmagazineCom::Application.routes.draw do
devise_for :users, :path_names => { :sign_up => "register"}, :controllers => { :registrations => "registrations" }
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
root 'magazine#index'
get 'users/' => 'users#index'
# Lobby Routes
# /log-in
devise_scope :user do
get '/sign-in' => 'devise/sessions#new'
end
# /subscribe
get 'subscribe' => 'subscribe#stepone'
get 'subscribe/sliding-scale' => 'subscribe#steptwo'
get 'subscribe/sliding-scale/subscriber' => 'subscribe#subscriber'
get 'subscribe/sliding-scale/supporter' => 'subscribe#supporter'
get 'subscribe/sliding-scale/sustainer' => 'subscribe#sustainer'
post 'subscribe/sliding-scale/:type' => 'subscribe#createSubscription'
# Pressroom Routes
get '/pressroom' => 'pressroom#index'
scope 'pressroom' do
resources :issues, :articles, :sections, :users, :authors
end
How can I pull out the show action and route it to the url that I described?
EDITED:
I've come up with what i want it to do in the routes file, but i need the corresponding controller code:
get '/:issue_slug/:section_slug/:article_slug' => 'article#show'