在routes.rb
中resources :restaurants do
collection do
get 'nearby'
end
resources :tickets
end
resources :users do
resources :tickets
end
如果我的控制器,我可以区分父资源
if params[:user_id].present?
@collection = User.find(params[:user_id])
else
@collection = Restaurant.find(params[:restaurant_id])
end
@ticket = @collection.tickets.new
但我如何区分,例如路径助手?
感谢。