rails2.1 不认 new_books_path,books是一个controller
[code="java"]
Name | |||
---|---|---|---|
'Are you sure?', :method => :delete %> |
<%= link_to 'New books', new_books_path %>[/code]
出错信息为:
NameError in Books#index
Showing books/index.html.erb where line #20 raised:
undefined local variable or method `new_books_path' for #ActionView::Base:0xb7371204
Extracted source (around line #20):
17:
18:
19:
20: <%= link_to 'New books', new_books_path %>
RAILS_ROOT: /home/jhzyb/myproject/test
Application Trace | Framework Trace | Full Trace
app/views/books/index.html.erb:20:in _run_erb_47app47views47books47index46html46erb'
index'
app/controllers/books_controller.rb:7:in
new_book_path
其实你可以在项目目录下执行rake routes,就会打印所有的路由
routes.eb里有没有加上这句?
map.resources :books