0
我正在嘗試爲我想展示的模型創建一些網址。我有文章,屬於屬於問題的章節。使用slu show展示動作的自定義路線
,我想我的文章show動作的URL看起來像這樣:
/issue-slug/section-slug/article-slug
問題的文章和部分具有被存儲在數據庫中蛞蝓。
現在我有一個叫'pressroom'的後臺部分,我有以下路線。這裏是整個的routes.rb文件
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
我如何拔出show動作並將其路由到我所描述的網址是什麼?
編輯:
我拿出我希望它在routes文件做的,但我需要相應的控制器代碼:
get '/:issue_slug/:section_slug/:article_slug' => 'article#show'
我已經使用friendly_id的蛞蝓,我很困惑什麼我需要把文章控制器的表演動作得到我想要的網址。 –
啊。我剛纔向你展示的那些資源就是'config/routes.rb'。你能爲我發佈你的整個路線文件嗎? – Dudo
其上面,我已經添加了您的路線 –