Bonjour à tous !
Comme beaucoup je débute l’apprentissage de ruby avec le livre “Ruby on
Rails 2e édition”. Je dois avoué que je suis bloqué avec le scaffold.
J’ai vu que son utilisation avait changé entre l’écriture du livre et
l’apparition de rail 2.0. J’ai donc adapté mais ca ne fonctione toujours
pas.
Erreur affichée :
undefined method
title' for #<Product id: nil></code> Extracted source (around line #8): <code>5: <% form_for(@product) do |f| %> 6: <p> 7: <b>Title</b><br /> 8: <%= f.text_field :title %> 9: </p> 10: 11: <p> </code> RAILS_ROOT: E:/C-web/Ruby/Test/depot <code>E:/C-web/Ruby/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/attribute_methods.rb:205:in
method_missing’
E:/C-web/Ruby/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_helper.rb:562:in
send' E:/C-web/Ruby/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_helper.rb:562:in
value_before_type_cast’
E:/C-web/Ruby/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_helper.rb:550:in
value_before_type_cast' E:/C-web/Ruby/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_helper.rb:465:in
to_input_field_tag’
E:/C-web/Ruby/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_helper.rb:289:in
text_field' E:/C-web/Ruby/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_helper.rb:640:in
send’
E:/C-web/Ruby/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_helper.rb:640:in
text_field' app/views/products/new.html.erb:8:in
_run_erb_47app47views47products47new46html46erb’
app/views/products/new.html.erb:5:in
_run_erb_47app47views47products47new46html46erb' app/controllers/products_controller.rb:29:in
new’
Il me semble pourtant avoir suivi la procédure :
Test>rails -d mysql depot
depot>ruby script/generate scaffold Product title:string desc
ription:text image_url:string
depot>rake db:migrate
depot>ruby script/server webrick
Quelqu’un peut-il m’aider ? Merci.