Error: ActiveRecord::RecordNotFound Couldn't find Option with 'id'=
This is happening when I add a link to the options show.html.erb
to get all the registrations for that option. In order to get the event id and the option id, I'm adding the following to the show method in the OptionsController:
@event = Event.find(params[:event_id])
@option = Option.find(params[:option_id])
This is the link I'm adding to the show.html.erb
file:
link_to "Registrations", event_option_registrations_path(@option)
This is how my 3 models look: Event, option and registrations
event.rb
:
class Event < ActiveRecord::Base
has_many :options, dependent: :destroy
end
option.rb
:
class Option < ActiveRecord::Base
belongs_to :event
has_many :registrations
end
routes.rb
:
resources :events do
resources :options do
resources :registrations
end
Route for Registrations:
event_option_registrations_path /events/:event_id/options/:option_id/registrations(.:format)
registrations#index