论坛首页 入门讨论版 rails

rails2.1 不认 new_books_path

浏览 137 次
该帖已经被评为新手帖
作者 正文
最后更新时间:2008-06-21 关键字: restful
rails2.1 不认 new_books_path,books是一个controller
   1. <h1>Listing books</h1>  
   2.   
   3. <table>  
   4.   <tr>  
   5.     <th>Name</th>  
   6.   </tr>  
   7.   
   8. <% for books in @books %>  
   9.   <tr>  
  10.     <td><%=h books.name %></td>  
  11.     <td><%= link_to 'Show', books %></td>  
  12.     <td><%= link_to 'Edit', edit_books_path(books) %></td>  
  13.     <td><%= link_to 'Destroy', books, :confirm => 'Are you sure?', :method => :delete %></td>  
  14.   </tr>  
  15. <% end %>  
  16. </table>  
  17.   
  18. <br />  
  19.   
  20. <%= link_to 'New books', new_books_path %>  

上面的index.html.erb是用scaffold 自动生成的
出错信息为:
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: <br />
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'
app/controllers/books_controller.rb:7:in `index'
   
最后更新时间:2008-06-21
<%= link_to 'New books', new_book_path %>
   
0 请登录后投票
论坛首页 入门讨论版 rails

跳转论坛:
JavaEye推荐