#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    13
    Rep Power
    0

    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?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    83
    Rep Power
    39
    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.

IMN logo majestic logo threadwatch logo seochat tools logo