Bonjour,

Moi aussi je débute avec RoR. Quand je fais un scaffold, je ne met pas
de majuscule au nom de la table.
Je met la liste des champs de ma table avec leur type : ruby script/
generate scaffold product title:string description:text
image_url:string
Puis je lance la commande. Après je vais dans db\migrate j'ouvre le
ficher généré et j'y apporte les compléments comme
":default=>false...".
Et enfin, je lance le rake db:migrate


On 27 nov, 08:32, Bobo Bobo <[email protected]> wrote:
> 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 :
> <code>undefined method `title' for #&lt;Product id: nil&gt;</code>
> Extracted source (around line #8):
> <code>5: &lt;% form_for(@product) do |f| %&gt;
> 6:   &lt;p&gt;
> 7:     &lt;b>Title&lt;/b>&lt;br /&gt;
> 8:     &lt;%= f.text_field :title %&gt;
> 9:   &lt;/p&gt;
> 10:
> 11:   &lt;p&gt;
> </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'</code>
>
> Il me semble pourtant avoir suivi la procédure :
> <code>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
> </code>
>
> Quelqu'un peut-il m'aider ? Merci.
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
Vous avez reçu ce message, car vous êtes abonné au groupe "Railsfrance" de 
Google Groups.
Pour transmettre des messages à ce groupe, envoyez un e-mail à l'adresse 
[email protected]
Pour résilier votre abonnement envoyez un e-mail à l'adresse 
[email protected]
-~----------~----~----~----~------~----~------~--~---

Répondre à