I have Event show page where I display a customer form for @customer
. If the event is a different kind of an event then I display a form for @registration and I want to post that form to RegistrationsController#create.
Right now in my routes I have this:
post '/:slug' => 'events#create', as: :registration
<%= simple_form_for @registration, url: custom_registration_path, html: { class: 'form, styled-form', autocomplete: 'off' } do |f| %>
...
<% end %>
The form above still posts to EventsController#create
I define @registration in EventsController#show
and I want to post the form to custom_registration_path.
How do I define the route? I still want to send the :slug
to RegistrationsController.
If I understood the situation correctly:
You can't have two routes with the same HTTP method & path. The method + path
combination has to be unique.
You either should route your custom registration to smth like custom_registrations/:slug
or change the path for events#create
Of course, you can use a different method for different actions. PUT
for example. But I'd consider it a bad practice as it's very implicit and will be hard to understand for anyone working with this code.