简体   繁体   中英

link_to => undefined method path

I have created an object Events and I have refactored the controller. Now I have that :

The view :

<td><%= link_to 'Show', event %></td>

The route :

scope 'admin', :module => 'back', :as => 'back' do
  root :to => 'events#index'
  resources :events
end

The controller :

class Back::EventsController < BackController

But I have an error undefined method event_path. So I have changed the link with :

<td><%= link_to 'Show', back_event %></td>

because when I make a rake routes I see that :

          back_event GET    /admin/events/:id(.:format)      back/events#show
                     PATCH  /admin/events/:id(.:format)      back/events#update
                     PUT    /admin/events/:id(.:format)      back/events#update
                     DELETE /admin/events/:id(.:format)      back/events#destroy

But now, I have the error : undefined local variable or method `back_event

How can I create this link ?

Thanks.

Eric

<td><%= link_to 'Show', back_event_path(event) %></td>

你真的需要花一些时间阅读基础知识: http//guides.rubyonrails.org/routing.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM