重要なお知らせ

「教えて! goo」は2025年9月17日(水)をもちまして、サービスを終了いたします。詳細はこちら>

電子書籍の厳選無料作品が豊富!

{"utf8"=>"✓",
"authenticity_token"=>"bqoR9tW+GGskvv4MRTtd1OikjwPKLeACkl7S/Pv55jE=",
"studylogheader"=>{"studydate"=>"2011-06-07",
"member_id"=>"902806575",
"comment_member"=>"頑張ったけど、だめだった。もうしんどい。",
"comment_staff"=>"comment_staff01",
"comment_parent"=>"comment_parent01"},
"studylogdetails"=>[{"starttime"=>{"(1i)"=>"2011",
"(2i)"=>"6",
"(3i)"=>"17",
"(4i)"=>"11",
"(5i)"=>"00"},
"endtime"=>{"(1i)"=>"2011",
"(2i)"=>"6",
"(3i)"=>"17",
"(4i)"=>"12",
"(5i)"=>"00"},
"place"=>"totto",
"studycontent"=>"aaaaa"},
{"place"=>"totto",
"studycontent"=>"aaaaa",
"starttime"=>{"(1i)"=>"2011",
"(2i)"=>"6",
"(3i)"=>"17",
"(4i)"=>"12",
"(5i)"=>"00"},
"endtime"=>{"(1i)"=>"2011",
"(2i)"=>"6",
"(3i)"=>"17",
"(4i)"=>"13",
"(5i)"=>"00"}},
{"place"=>"totto",
"studycontent"=>"aaaaa",
"starttime"=>{"(1i)"=>"2011",
"(2i)"=>"6",
"(3i)"=>"17",
"(4i)"=>"07",
"(5i)"=>"47"},
"endtime"=>{"(1i)"=>"2011",
"(2i)"=>"6",
"(3i)"=>"17",
"(4i)"=>"07",
"(5i)"=>"47"}},
{"place"=>"totto",
"studycontent"=>"aaaaa",
"starttime"=>{"(1i)"=>"2011",
"(2i)"=>"6",
"(3i)"=>"17",
"(4i)"=>"07",
"(5i)"=>"47"},
"endtime"=>{"(1i)"=>"2011",
"(2i)"=>"6",
"(3i)"=>"17",
"(4i)"=>"07",
"(5i)"=>"47"}},
{"place"=>"totto",
"studycontent"=>"aaaaa",
"starttime"=>{"(1i)"=>"2011",
"(2i)"=>"6",
"(3i)"=>"17",
"(4i)"=>"07",
"(5i)"=>"47"},
"endtime"=>{"(1i)"=>"2011",
"(2i)"=>"6",
"(3i)"=>"17",
"(4i)"=>"07",
"(5i)"=>"47"}},
{"place"=>"totto",
"studycontent"=>"aaaaa"}],
"commit"=>"Save changes"}

上記のような params です。

01: index = 0
02: params[:studylogdetails].map { |hash|
03: studylogdetails[index].starttime =
04: Time.new(
05: hash[:starttime]["(1i)"].to_i,
06: hash[:starttime]["(2i)"].to_i,
07: hash[:starttime]["(3i)"].to_i,
08: hash[:starttime]["(4i)"].to_i,
09: hash[:starttime]["(5i)"].to_i, 0)
10: ......<中略>
11: studylogdetails[index].save
12: index = index + 1
13: }

このようなコードで、行05 で以下のようなエラーになります。

You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]

どなたかわかる方、お願いします。

A 回答 (1件)

つまり上記のような params じゃねぇってことだよ。


そして変数 index が謎すぎる。

この回答への補足

(1i) ← これが怪しいのですかね。。。。うまく行ってる所は、studydate(1i) とかってなってます。。。。

補足日時:2011/06/17 20:28
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!