2012-04-10 90 views
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 

,但我怎麼能區分,例如,路徑幫手?

謝謝。

回答