ruby on rails - Object doesn't support #inspect when used with .include -
So I have participated in a glitch error that I do not even know how to debug. I am very new to the railing, so it has kicked my ass well when I use the .includes (school)
seen by the student, it gives a blue box error, But when I look at any other model and .includes (school)
, the school works just fine.
class student & lt; ActiveRecord :: Base has has_many: relationships, foreign_key: "liker_id", dependent :: has_many: matches, foreign_key: "student_1_id", dependent :: deleted belong_to: school belong_to: conference belong_to: would_you_rather belong_to: home city belong_to: year is_to: Major and class school & lt;
on the console
activatecord :: Affiliate for the base: conference includes: respondent, class: "school", foreign_key: "rival_id" (e.g. For: School) Select
SQL generated
Select "School". * "School" from "school" "ID" IN (1)
error message back
NoMethodError: undefined method `for each 'zero: NilClass /.rvm/gems/ruby -2.1.2 / gems / activerecord4.1.1 / lib / active_record / associations / preloader / association.rb: 87: in_in_in_older_in_all_older_frame/rvm/gems/by ruby-2.1 to 2. Gemstone / ActiveRecord-4.1.1 / lib / active_record / Associations / preloader / association.rb: 86: lib / active_record / associations / preloader / association.rb: 86: `/ 'from /.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.1/ in` each' /.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.1/lib/active_record/associations/preloader/singular_association.rb to associate_records_by_owner ': 9: /.rvm/gems/ruby-2.1.2/ Gems / activerecord-4.1.1 / lib / active_record / associations / preloader / association.rb: 20: in / from 'preload' /.rvm/gems The 'run' /ruby-2.1.2/gems/activerecord-4.1.1/lib/active_record/associations/preloader.rb:136:IN 'block in preloaders_for_one (2 level) / /rvm/gems/ruby-2.1. 2 / 'Gem / ActiveRecord-4.1.1 / lib / active_record / Associations / preloader.rb: 134: /' rvm/gems/ruby-2.1.2/gems/activerecord-4.1.1/lib/ 'in each' In 'map' from active_record / associations /preloader.rb:134:IN /'rvm/gems/ruby-2.1.2/gems/activerecord-4.1.1/lib/active_record/associations/preloader.rb:134:IN 'Preloaders_for_one block'
Before asking a question before and just
d = Student.where (: id = & gt; '1'). (School)
prepares the console
Select student loads (0.6ms) "students" * Select "Students" "ID" = 1 School Load (0.2 MMS) "School". * "Schools" where "School" In "id" (1) (object does not support #ist) = & gt;
and gives a completely empty line
I'm sure there is an error here, I do not know how to solve it. I am also new to the stack overflow, so if I miss anything, please do not hesitate to ask me
> School_id < / Code> column is defined as
string
? The train did not like it until recently. Two options:
- Upgrade to the latest version of the train (now as
4.1.4
). - Change the column type to integer (or UUID)
Comments
Post a Comment