Note that there are some explanatory texts on larger screens.

plurals
  1. PORails Server requiring restart to show changes
    text
    copied!<p>I'm currently learning Ruby on Rails with the help of the Book "Agile Web Development with Rails", but I have a problem with the first application.</p> <p>I created the app with <code>rails new depot</code> and generated the scaffold with </p> <pre><code>rails generate scaffold Product \title:string description:text image_url:string price:decimal </code></pre> <p>Then I ran <code>rake db:migrate</code></p> <p>According to the book I should now be able to create new Products which would then display immediately. But when adding a new Product it does not show up when viewing the url <code>http://localhost:3000/products</code> or <code>http://localhost:3000/products.json</code>, When I view the database file the added products are there.</p> <p>The added Products show up in the list after I restarted the server. Does anybody know what I've done wrong?</p> <p>Using: Rails 3.2.4, Ruby 1.9.3, WEBrick 1.3.1, SQLite 3 and Mac OSX</p> <p>EDIT: Code generated by the scaffold:</p> <pre><code> products_controller.rb # GET /products # GET /products.json def index @products = Product.all respond_to do |format| format.html # index.html.erb format.json { render json: @products } end end index.html.erb &lt;h1&gt;Listing products&lt;/h1&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;Title&lt;/th&gt; &lt;th&gt;Description&lt;/th&gt; &lt;th&gt;Image url&lt;/th&gt; &lt;th&gt;Price&lt;/th&gt; &lt;th&gt;&lt;/th&gt; &lt;th&gt;&lt;/th&gt; &lt;th&gt;&lt;/th&gt; &lt;/tr&gt; &lt;% @products.each do |product| %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= product.title %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= product.description %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= product.image_url %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= product.price %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= link_to 'Show', product %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= link_to 'Edit', edit_product_path(product) %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= link_to 'Destroy', product, confirm: 'Are you sure?', method: :delete %&gt;&lt;/td&gt; &lt;/tr&gt; &lt;% end %&gt; &lt;/table&gt; &lt;br /&gt; &lt;%= link_to 'New Product', new_product_path %&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload