0

I am trying to make some alias for my rails route like this 'events/8/event_participants/new' to /business-meet/registration, My routes are written like this:

  resources :events, only: [], shallow: true do
    resources :event_participants, only: [:new, :create, :edit, :update] do
      post :complete, on: :collection

      member do
        get :invite, :add_people, :accept_invitation, :invitation_success, :reserved
        put :refer
      end
    end
  end

I want the alias for the specific event id 8, I tried with redirect, but it actually redirect to the the route, so the whole route is visible in the browser, I want the to keep visible /business-meet/registration routes to my browser.

suvodipMondal
  • 656
  • 10
  • 27

1 Answers1

1

You can use a match method in your route.

match '/business-meet/registration', to: 'event_participants#new', via: :get, defaults: { event_id: 8 }
Hass
  • 1,628
  • 1
  • 18
  • 31
  • I do not have any events controller as I do not have to do any operation in events, It is giving this error `Routing Error uninitialized constant Events`, event if I make empty EventsController it is not working – suvodipMondal Sep 07 '20 at 19:58
  • Then how do you know the event? You can remove the events from the route. I’ve updated the answer. – Hass Sep 08 '20 at 00:28
  • You can see how my route is defined for that part in my question – suvodipMondal Sep 08 '20 at 01:45
  • I still can’t see your controller and which param 8 is matched to. Did the update not work? I think you need to tweak it to match your code but this is the answer as to how you do it. – Hass Sep 08 '20 at 01:55