small medium large xlarge

Benyoskovitz_profile_pragsmall
21 Jul 2010, 11:21
Ben Yoskovitz (3 posts)

I’ve just started Chapter 6 on Depot. I get to the point where I click New product in the browser and it spits out the following error:

SyntaxError in Products#new

Showing app/views/products/new.html.erb where line #7 raised:

compile error /Users/ben/Desktop/depot/app/views/products/new.html.erb:7: syntax error, unexpected ‘:’, expecting ‘)’ …tput_buffer.concat(( f.label : title ).to_s); @output_buffer… ^ /Users/ben/Desktop/depot/app/views/products/new.html.erb:8: syntax error, unexpected ‘:’, expecting ‘)’ …buffer.concat(( f.text_field : title ).to_s); @output_buffer… ^ Extracted source (around line #7):

4: <%= f.error_messages %> 5: 6: <p> 7: <%= f.label : title %>
8: <%= f.text_field : title %> 9: </p> 10: <p> Trace of template inclusion: app/views/products/new.html.erb

I’ve looked at new.html.erb - there’s not much in there except for the basic form for adding a product. I’m wondering if this is an issue with Rails and Ruby versions?

Rails 2.3.8 Ruby 1.8.7

Any help is appreciated!

Benyoskovitz_profile_pragsmall
21 Jul 2010, 13:08
Ben Yoskovitz (3 posts)

I should point out that new.html.erb looks like this:

New product

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

<%= f.label : title %>
<%= f.text_field : title %>

<%= f.label :description %>
<%= f.text_area :description %>

<%= f.label :image_url %>
<%= f.text_field :image_url %>

<%= f.submit ‘Create’ %>

<% end %>

<%= link_to ‘Back’, products_path %>

Benyoskovitz_profile_pragsmall
21 Jul 2010, 13:15
Ben Yoskovitz (3 posts)

Looks like spacing between : and title – removed that and it worked. But got another error:

undefined method `title’ for #<Product id: nil, created_at: nil, updated_at: nil>

In this post : http://forums.pragprog.com/forums/66/topics/2361 – it says that the database wasn’t migrated, for someone with a similar problem. And suggests:

rake db:migrate

I do that and nothing happens. I don’t get any output in Terminal and the app still doesn’t work.

You must be logged in to comment