small medium large xlarge

30 Mar 2009, 02:46
Kirk Hayes (4 posts)

So has anyone else run into this? I did a scaffold command using the mysql database and evidently it has not put the “:” in the correct places in the migrate file nor on several of the html.erb files.

I had to edit the new.products.html.erb : `

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

should be

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


Notice the removal of the space between ` “:” and “table” `

31 Mar 2009, 14:18
Christian Lemp (1 post)

Kirk, did changing the space fix your problem? I also have a problem at this point in the book (sorry for jacking your thread, but it seems relevant).

I am running Rails 2.3.2, and I can follow every step up to this point with no interruptions, however, when I click ‘New Product’ I get an error. Here is the log file:

Processing ProductsController#new (for at 2009-03-31 09:51:29) [GET]
  Product Columns (7.0ms)   SHOW FIELDS FROM `products`
Rendering template within layouts/products
Rendering products/new

ActionView::TemplateError (undefined method `title' for #<Product id: nil, created_at: nil, updated_at: nil>) on line #8 of app/views/products/new.html.erb:
6:   <p><!--
7:     <%= f.label :title %><br />
8:     <%= f.text_field :title %>	
9:   -->
10:   </p>
11:   <p>

    app/controllers/products_controller.rb:29:in `new'
    C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
    C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'

Rendered rescues/_trace (207.0ms)
Rendered rescues/_request_and_response (0.0ms)
Rendering rescues/layout (internal_server_error)

How can I fix this?

25 Aug 2009, 04:13
David Southard (1 post)

Sounds like you haven’t migrated the database and also you’re using html commenting “<!--" and "-->” there is no need for that here.

:>rake db:migrate

Just putting this here for posterity’s sake in case anyone comes across this.

You must be logged in to comment