各位大俠大家好:
為了方便讓大家明白我的問題,也怕我水平不足無法正確陳述問題。我附上一些圖片 但不知會不會被和蟹掉。如果看不到圖請不吝告之那邊有可以正常運作的圖片網站我再去註冊。
Student.joins(:student_incomelevelships => {:incomelevels => :student})
我想把它們 joins 一起再由 view 那兒做出選單大概類似 squeel 範例裏所述的
Person.joins(:articles => {:comments => :person}) => SELECT "people".* FROM people" INNER JOIN "articles" ON "articles"."person_id" = "people"."id" INNER
JOIN "comments" ON "comments"."article_id" = "articles"."id" INNER JOIN "people" people_comments" ON "people_comments"."id" = "comments"."person_id"
當我用這個指令時
Student.joins(:student_incomelevelships => {:incomelevels => :student})
卻一直出現底下的錯誤訊息
ruby-1.9.2-p290 :018 > Student.joins(:student_incomelevelships => {:incomelevels => :student}) ActiveRecord::ConfigurationError: Association named 'student_incomelevelships' was not found; perhaps you misspelled it?
from /home/kojendirect/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.7/lib/active_record /associations.rb:1944:in build' from /home/kojendirect/.rvm/gems/ruby-1.9.2-p290/gems/polyamorous-0.5.0/lib/polyamorous/join_dependency.rb:52:inbuild_with_polymorphism' from /home/kojendirect/.rvm/gems/ruby-1.9.2-p290/gems/squeel-0.9.5/lib/squeel/adapters/active_record/join_dependency_extensions.rb:29:in `build_with_squeel'
請問這是什麼原因造成的?還是我指令有錯?