Ruby on Rails的嵌套的路線,我有兩個型號:與HAS_ONE協會
預訂:
class Reservation < ActiveRecord::Base
has_one :car_emission
end
CarEmission:
class CarEmission < ActiveRecord::Base
belongs_to :reservation
end
及以下路線:
resources :reservations do
resources :car_emissions
end
現在當我想要創建新car_emission我必須訪問的URL是這樣的:
http://localhost:3000/reservations/1/car_emissions/new
,當我想編輯我的必遊:
http://localhost:3000/reservations/1/car_emissions/1/edit
反正是有改變路線,我car_emission編輯鏈接看起來就像這樣:
http://localhost:3000/reservations/1/car_emission