我对如何为我的表演活动整理路线感到困惑。目前,如果我选择特定的指南来“显示”它,网址会说
/准则/1
其中 1 是指南 ID
我想说
/标题
(这是正在显示的指南的标题)。我很困惑如何在我的路线中管理这个。目前我的路线有
get 'guideline/:id', to: 'guidelines#show', as: :seeguideline
但这只是我提到的guideline/1,所以我意识到我做错了什么
我的观点与此链接
<%= link_to guideline.title, seeguideline_path(id: guideline.id) %>
在guidelines_controller.rb 中显示操作是
def show
@guideline = Guideline.where(title: params[:title]).first
respond_to do |format|
format.html # show.html.erb
format.json { render json: @guideline }
end
end
路线是
ActiveAdmin.routes(self)
devise_for :admin_user, ActiveAdmin::Devise.config
get "guidelines/topic"
get "guidelines/topichospital"
get "guidelines/topicspecialty"
get "guidelines/favourite"
devise_for :users
devise_scope :user do
get 'signup', to: 'devise/registrations#new', as: :register
get 'login', to: 'devise/sessions#new', as: :login
get 'logout', to: 'devise/sessions#destroy', as: :logout
get 'edit', to: 'devise/registrations#edit', as: :edit
put 'users' => 'devise/registrations#update', :as => 'user_registration'
get 'about', to: 'about#about', as: :about
end
resources :guidelines
get 'guidelines', to: 'guidelines#index', as: :guidelines
get 'favourites', to: "favourites#show", as: :favourites
get 'topics', to: 'guidelines#list', as: :topics
get 'hospitals', to: 'guidelines#listhospital', as: :hospitals
get 'specialties', to: 'guidelines#listspecialty', as: :specialties
root :to => 'guidelines#index'
get '/:id', to: 'profiles#show', as: :myprofile
get '/:title', to: 'guidelines#show', as: :seeguideline