2012-04-17 7 views
1
abstract (1.0.0) 
actionmailer (3.2.2, 3.0.10, 3.0.5, 3.0.3, 2.3.5, 2.1.0) 
actionpack (3.2.2, 3.0.10, 3.0.5, 3.0.3, 3.0.0.beta3, 2.3.5, 2.1.0) 
activemodel (3.2.2, 3.0.10, 3.0.5, 3.0.3, 3.0.0.beta3) 
activerecord (3.0.10) 
activeresource (3.2.2, 3.0.10, 3.0.5, 3.0.3, 2.3.5, 2.1.0) 
activesupport (3.2.2, 3.0.10, 3.0.5, 3.0.3, 3.0.0.beta3, 2.3.5, 2.1.0) 
arel (3.0.2, 2.0.10, 2.0.6) 
bcrypt-ruby (3.0.1, 2.1.2) 
bson (1.1.5) 
bson_ext (1.1.5) 
builder (3.0.0, 2.1.2) 
bundle (0.0.1) 
bundler (1.1.3, 1.1.1, 1.1.0) 
cancan (1.6.7, 1.4.1) 
coffee-rails (3.2.2) 
coffee-script (2.2.0) 
coffee-script-source (1.3.1, 1.2.0) 
devise (2.0.4, 1.5.3, 1.1.5) 
erubis (2.7.0, 2.6.6) 
execjs (1.3.0) 
hike (1.2.1) 
i18n (0.6.0, 0.5.0, 0.3.7) 
journey (1.0.3) 
jquery-rails (2.0.2, 2.0.1) 
jquery_datepicker (0.3.4) 
json (1.6.6, 1.6.5) 
libv8 (3.3.10.4 x86-linux) 
mail (2.4.4, 2.2.19, 2.2.12, 2.2.7) 
memcache-client (1.8.5) 
mime-types (1.18, 1.17.2, 1.16) 
mongo (1.1.5) 
mongoid (2.0.0.beta.20) 
multi_json (1.2.0) 
mysql2 (0.3.11) 
nifty-generators (0.4.2) 
orm_adapter (0.0.7) 
polyglot (0.3.3, 0.3.1) 
rack (1.4.1, 1.2.5, 1.2.1, 1.1.3, 1.0.1) 
rack-cache (1.2) 
rack-mount (0.6.14, 0.6.13) 
rack-ssl (1.3.2) 
rack-test (0.6.1, 0.5.7, 0.5.6) 
rails (3.0.10) 
railties (3.2.2, 3.0.10, 3.0.5, 3.0.3) 
rake (0.9.2.2, 0.8.7) 
rdoc (3.12) 
rolify (3.1.0) 
sass (3.1.15) 
sass-rails (3.2.5) 
sprockets (2.1.2) 
sqlite3 (1.3.5) 
therubyracer (0.9.10) 
thor (0.14.6) 
tilt (1.3.3) 
treetop (1.4.10, 1.4.9) 
tzinfo (0.3.33, 0.3.32, 0.3.23) 
uglifier (1.2.4) 
warden (1.1.1, 1.0.3) 
will_paginate (3.0.3, 3.0.pre2) 

は、宝石のリスト..ですルビー:Railsの3.0.10ではありません方法の誤りの上

私は、サブタスクは、各タスク内で定義されています基本的なTODOが、コマンドでtask=Todo.tasks.new結果を維持しています何のメソッドエラー

[email protected]:~/mytodos$ rails console 
Loading development environment (Rails 3.0.10) 
1.9.2-p290 :001 > todo=todo.first 
NoMethodError: You have a nil object when you didn't expect it! 
You might have expected an instance of Array. 
The error occurred while evaluating nil.first 
    from (irb):1 
    from /home/amrit/.rvm/gems/[email protected]/gems/railties-3.0.10/lib/rails/commands/console.rb:44:in `start' 
    from /home/amrit/.rvm/gems/[email protected]/gems/railties-3.0.10/lib/rails/commands/console.rb:8:in `start' 
    from /home/amrit/.rvm/gems/[email protected]/gems/railties-3.0.10/lib/rails/commands.rb:23:in `<top (required)>' 
    from script/rails:6:in `require' 
    from script/rails:6:in `<main>' 
1.9.2-p290 :002 > todo=Todo.first 
=> #<Todo id: 1, name: "Office", description: "work to be completed at office", created_at: "2012-04-17 08:53:35", updated_at: "2012-04-17 08:53:35"> 
1.9.2-p290 :003 > task=Todo.tasks.new 
NoMethodError: undefined method `tasks' for #<Class:0xae32588> 
    from /home/amrit/.rvm/gems/[email protected]/gems/activerecord-3.0.10/lib/active_record/base.rb:1014:in `method_missing' 
    from (irb):3 
    from /home/amrit/.rvm/gems/[email protected]/gems/railties-3.0.10/lib/rails/commands/console.rb:44:in `start' 
    from /home/amrit/.rvm/gems/[email protected]/gems/railties-3.0.10/lib/rails/commands/console.rb:8:in `start' 
    from /home/amrit/.rvm/gems/[email protected]/gems/railties-3.0.10/lib/rails/commands.rb:23:in `<top (required)>' 
    from script/rails:6:in `require' 
    from script/rails:6:in `<main>' 
1.9.2-p290 :004 > ^C 
1.9.2-p290 :004 > t=Task.new 
=> #<Task id: nil, description: nil, due_date: nil, due_time: nil, completed: nil, todo_id: nil, created_at: nil, updated_at: nil> 
1.9.2-p290 :005 > t.description="meeting" 
=> "meeting" 
1.9.2-p290 :006 > t.save 
=> true 
1.9.2-p290 :007 > task=Todo.tasks.new 
NoMethodError: undefined method `tasks' for #<Class:0xae32588> 
    from /home/amrit/.rvm/gems/[email protected]/gems/activerecord-3.0.10/lib/active_record/base.rb:1014:in `method_missing' 
    from (irb):7 
    from /home/amrit/.rvm/gems/[email protected]/gems/railties-3.0.10/lib/rails/commands/console.rb:44:in `start' 
    from /home/amrit/.rvm/gems/[email protected]/gems/railties-3.0.10/lib/rails/commands/console.rb:8:in `start' 
    from /home/amrit/.rvm/gems/[email protected]/gems/railties-3.0.10/lib/rails/commands.rb:23:in `<top (required)>' 
    from script/rails:6:in `require' 
    from script/rails:6:in `<main>' 
1.9.2-p290 :008 > 
+0

エラーメッセージだけを入力してください.... **人間**読み取り可能:P – uday

答えて

0

おかげで(あなたは藤堂と呼ばれるARモデルを持っていると仮定すると)!!私はこれを試していたインスタンスを作成している間に私が間違っている答えを得ました:t = Todo.new t = Todo.tasks.newの代わりに:t = Todo.new x = t.tasks。

1

はおそらく意図せず代わりにインスタンスのクラスにtasksを呼び出すことはありません。代わりにこれを試してみてください:

task=todo.tasks.new 
+0

ありがとうございます! トン= Todo.new トン= Todo.tasks.new の代わり:: トン= Todo.new のx =のt.tasks私は、私はこれをしようとしていたインスタンス を作成しながら、私は間違いをしていた答えを得ました.new 私はtodo内でタスクを作成しようとしていたので – Aayush

0

これはあなたが

todo=todo.firstをやっている、単純なタイプミスであるように思えるが、2番目のtodoは何ですか?あなたが資本「T」で行う第二の例を確認し、それを修正しようとしたり、

todo = Todo.all.first 

を試すことができますが、それを定義していない、しかし、あなたの第二の例では、あなたが

todo=Todo.first 

を行うようにだって思えますあなたは

歓声