vendredi 17 avril 2015

Rails routes url edit_path

I'm having a problem with my routes:



No route matches events/edit_national_event


The generated URL : http://localhost:3000/events/edit_national_event.:id


I need : http://localhost:3000/events/:id/edit_national_event


it works with destroy but not with edit. What is wrong with my code ?


routes :



resources :events, only: [:index, :destroy] do
collection do
get :new_national_event
get :new_local_event
post :create_national_event
post :create_local_event
end
member do
get :edit_national_event
get :edit_local_event
put :update_national_event
put :update_local_event
end
end


Event-controllor :



def edit_national_event
@event = Event.find(params[:id])
end


view :



@group_events.each do |event|
tr
td
=event.title
td
=link_to edit_national_event_event_path(event)
=link_to event_path(event), method: :delete


When I'm doing rake routes :



new_national_event_events GET /events/new_national_event(.:format) events#new_national_event
new_local_event_events GET /events/new_local_event(.:format) events#new_local_event
create_national_event_events POST /events/create_national_event(.:format) events#create_national_event
create_local_event_events POST /events/create_local_event(.:format) events#create_local_event
edit_national_event_event GET /events/:id/edit_national_event(.:format) events#edit_national_event
edit_local_event_event GET /events/:id/edit_local_event(.:format) events#edit_local_event
update_national_event_event PUT /events/:id/update_national_event(.:format) events#update_national_event
update_local_event_event PUT /events/:id/update_local_event(.:format) events#update_local_event
events GET /events(.:format) events#index
event DELETE /events/:id(.:format) events#destroy

Aucun commentaire:

Enregistrer un commentaire