0
votes

I am beginner rails developer. I have this question: I've a resource in my routes. resource

  resources :events, only: [:index, :show, :comment] do
    member do
      post :comment
      get :will_go
    end
  end

then in Event model I've this relation event belongs_to city and in the city model city has_many events

I using friendly_id gem, for do my own routes. Now i have link to event like: http://localhost:3000/events/moscow/concert_of_madonna/49 where moscow - is the title of city concert_of_madonna - is slug of title of event 49 is event id

But we need to do something like this: http://localhost:3000/moscow/events/concert_of_madonna/49 so i need to switch city title and resource .

I know that I can do it with routes, but i have no success.

What can I do?

1

1 Answers

1
votes

I think what you are looking for is scope:

scope ':city' do
  resources :events, only: [:index, :show, :comment] do
    member do
      post :comment
      get :will_go
    end
  end
end