[Rails] How to add a link ?
I followed a RoR guide at http://guides.rubyonrails.org/getting_started.html
.
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
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home