I followed a RoR guide at Getting Started with Rails — Ruby on Rails Guides . At 6.2(Adding a link) ,i got a error.I Open app/views/home/ index.html.erb and modify it as follows:
<h1>Hello, Rails!</h1> <%= link_to "My Blog", posts_path %> Now started server ,and when i click on "My blog",it gave following error
NameError in Posts#index
Showing /home/amrit/blog/app/views/posts/index.html.erb where line #28 raised:
undefined local variable or method `new_posts_path' for #<#<Class: 0xb67c1918>:0xb67c09f0>
The contents of app/view/posts/index.html.erb file are as follow
<h1>Listing posts</h1>
<table> <tr> <th>Name</th> <th>Title</th> <th>Content</th> <th></th> <th></th> <th></th> </tr>
<% @posts.each do |post| %> <tr> <td><%= post.name %></td> <td><%= post.title %></td> <td><%= post.content %></td> <td><%= link_to 'Show', post %></td> <td><%= link_to 'Edit', edit_post_path(post) %></td> <td><%= link_to 'Destroy', post, :confirm => 'Are you sure?', :method => :delete %></td> </tr> <% end %> </table>
<br />
<%= link_to 'New posts', new_posts_path%>
I am using ubuntu 10.04 and rails 3.07.
Thanks