Undefined method with “_path” while using rails form_for

Only routes created using the resources method are automatically named.

If you want to name your routes, use the :as option:

match '/static-events/new', :to => 'static_events#new', :as => :new_static_event
match '/static-events/',     :to => 'static_events#index', :as => :static_events
match '/static-events/:id', :to => 'static_events#show', :as => :static_event

However, it’s better to use the resources method. You must pass the “true” name of your model as the first parameter, then override the path if you want:

resources :static_events, :path => 'static-events'

Leave a Comment

techhipbettruvabetnorabahisbahis forumu