您好我已經從鐵軌4.0.0至4.1.0升級和得到這個錯誤:Rails未定義的方法`收集'爲1:Fixnum,如何解決它?
undefined method `collect' for 1:Fixnum
在此代碼
剪斷:
@data[:weekday] ||= XYZ.count(:include => [:membership],
:conditions => ["xyz.done_at IS NOT NULL AND memberships.course_id = ?", @course_id],
:group => "WEEKDAY(xyz.done_at)").collect {| val | [val[0].to_i, val[1]]}
問題特別ocurrs這部分
.collect {| val | [val[0].to_i, val[1]]}
可能是什麼問題?
改變的地方,我有這個後:
@data[:weekday] ||= XYZ.joins("membership").where("done_at IS NOT NULL AND memberships.course_id = ?", @course_id).group("WEEKDAY(done_at)").collect {| val | [val[0].to_i, val[1]]}
,並得到這個錯誤:
Error: Unknown table 'xyz': SELECT `xyz`.* FROM `xyz` membership WHERE (done_at IS NOT NULL AND memberships.course_id = 2) GROUP BY WEEKDAY(done_at)
Schema.rb
create_table "xyz", :force => true do |t|
t.datetime "send_at"
t.datetime "done_at"
t.string "hash_for_url", :null => false
t.integer "membership_id", :null => false
t.integer "lesson_text_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.text "json_answers"
t.boolean "worked"
t.boolean "passed"
t.boolean "checked"
t.datetime "opened_at"
t.text "rendered_result"
t.datetime "remind_at"
end
add_index "xyz", ["done_at"], :name => "index_xyz_on_done_at"
add_index "xyz", ["membership_id"], :name => "index_xyz_on_membership_id"
add_index "xyz", ["send_at"], :name => "index_xyz_on_send_at"
請在問題中包含'schema.rb'的相關部分。 – Drenmi
你需要哪些零件? – Felix
與XYZ模型相關的部分。 – Drenmi