1

This question is quite similar to this one, but it hasn't helped me enough to get what I wanted

Starting with the model "event", I'd need to cut the form if different tabs, and for each tab, having a specific url, for example :

/event/:id/edit/:tab_name

If I add this route as a member :

resources :events do
  member do
    get "/:tab_name", :to => "events#edit", as: :tab
  end
end

The tab_name parameter remains dirty /event/:id/edit?tab_name=mytab while using tab_event_path(@event, :tab_name => "mytab")

But Id like a clean route (or at least understand how)

I managed to do what I wanted with the following :

resources :events, :except => [:edit] do
    collection do
        get "/:id/edit(/:tab)", :to => "events#edit", :as => :edit
    end
end

but as far as I can get it, this route should remain a member

Assuming it might not be the right pattern to choose, but thanks in advance for any answer on this one

4

1 回答 1

1

您可以尝试以下方法:

resources :events, :except => [:edit] do
  member do
    get "edit/:tab_name", to: "events#edit", as: 'edit_tab'
  end
end
于 2016-12-30T14:19:43.193 回答