Reputation: 73
So I have two models a booker
and a booking_ticket
. I have nested the routes of booking_ticket
under booker
, but I also want to create a new booking_ticket
without a booker
, so I created a custom route. My action works properly when I try to create using the nested route but not on my custom path.
my routes.rb
resources :bookers do
resources :booking_tickets
end
get '/booking_tickets/new', to: 'booking_tickets#new', as: 'new_booking_ticket'
This is the error I'm getting from rails when I use the custom path:
I don't understand where the error is coming from.
Upvotes: 0
Views: 99
Reputation: 10517
You need to create a custom route for create
action, your current custom resource is for new
action:
post '/booking_tickets/create', to: 'booking_tickets#create'
Or, since you seem to be using defaults, just replace your current custom route with:
resources :booking_tickets, only: [:new, :create]
Be sure to add it outside resources :bookers
block:
resources :bookers do
resources :booking_tickets
end
resources :booking_tickets, only: [:new, :create]
Upvotes: 2