浏览 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' 声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|
| 返回顶楼 | |
|
最后更新时间:2008-06-21
<%= link_to 'New books', new_book_path %>
|
|
| 返回顶楼 | |


