dimanche 30 août 2015

Form not showing up - Ruby on Rails

I'm currently following a Ruby on Rails tutorial book and I've noticed that the newer version of Rails is quite a bit different. A couple of given commands were different than described in the book and I've had to look up a few ways on how to fix these things. Right now though, I don't know what's going wrong. I have created a database table products and I'm simply trying to use a form to display some input components etc to create a new product. The book told me to do this:

<h1>New product</h1>

<% form_for(@product) do |f| %>
    <%= f.error_messages %>

<p>
    <%= f.label :title %><br />
    <%= f.text_field :title %>
</p>
<p>
    <%= f.label :description %><br />
    <%= f.text_area :description, :rows => 6 %>
</p>
<p>
    <%= f.label :image_url %><br />
    <%= f.text_field :image_url %>
</p>
<p>
    <%= f.label :price %><br />
    <%= f.text_field :price %>
</p>
<p>
    <%= f.submit "Create" %>
</p>
<% end %>

<%= link_to 'Back', products_path %>

However, the view only shows me the New product header and the link to go back. I've already installed a different gem because the f.error_messages apparently wasn't used anymore either. The problem is, the entire form_for part does not show up anything. Can anybody tell me how I am supposed to change this code to get it to show up on the view for creating a new product?

Thanks!

This is what it shows:

enter image description here

Aucun commentaire:

Enregistrer un commentaire