0

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

しかし、たとえばパスヘルパーをどのように区別できますか?

ありがとう。

4

1 に答える 1

0

polymorphic_pathを参照してください。

于 2012-04-10T10:30:19.153 に答える