August 9th, 2012, 12:42 PM
-
Adding a 'body' field to a .html.erb file
Hi, I have the following Ruby file (.html.erb):
Code:
<h1>Listing posts</h1>
<table>
<tr>
<th>Title</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @posts.each do |post| %>
<tr>
<td><%= post.title %></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 Post', new_post_path %>
and I'm following a tutorial which says to edit the file to also include the body field, which I've done so that my page now looks like this:
Code:
<h1>Listing posts</h1>
<table>
<tr>
<th>Title</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @posts.each do |post| %>
<tr>
<td><%= post.title %></td>
<td><%= post.body %></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 Post', new_post_path %>
The tutorial then says to reload the web page, and notice the new field. However, when I reload the web page, I get an error saying that "Firefox can't establish a connection to the server at localhost:3000"
Does anyone know why I'm getting the error page? What can I do so that I can view my page with the new field?
August 10th, 2012, 09:17 AM
-
Either the server crashed (which shouldn't happen - certainly not from just editing a template) or you accidentally shut it down. Just restart the server and try again. If it doesn't start, post the error message here and hopefully we can help you with that.