I have two models:
Reservation:
class Reservation < ActiveRecord::Base
has_one :car_emission
end
CarEmission:
class CarEmission < ActiveRecord::Base
belongs_to :reservation
end
and the following routes:
resources :reservations do
resources :car_emissions
end
Now that I want to create a new car_emission, I have to visit the url, like this:
http://localhost:3000/reservations/1/car_emissions/new
and when I want to edit, I have to visit:
http://localhost:3000/reservations/1/car_emissions/1/edit
Is there a way to change the routes along which my link to edit car_emission would look like this:
http://localhost:3000/reservations/1/car_emission
source
share