Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #do I have the stupids today, or is this just a bit weird?
- class Categorization < ActiveRecord::Base
- belongs_to :category
- belongs_to :categorized_content, :polymorphic => true
- end
- ?> cat
- => #<Category id: 528, category_type_id: 1, parent_id: 219, name: "Brolgas", created_at: "2010-02-04 01:49:53", updated_at: "2010-02-04 01:49:53">
- >> cat.categorizations
- => [#<Categorization id: 2, category_id: 528, categorized_content_id: 2, categorized_content_type: "Dataset", created_at: "2010-02-04 02:39:20", updated_at: "2010-02-04 02:39:20">]
- >> cat.categorizations.first
- => #<Categorization id: 2, category_id: 528, categorized_content_id: 2, categorized_content_type: "Dataset", created_at: "2010-02-04 02:39:20", updated_at: "2010-02-04 02:39:20">
- >> cat.categorizations.first.category
- 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.include?
- from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:142:in `create_time_zone_conversion_attribute?'
- from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:75:in `define_attribute_methods'
- from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:71:in `each'
- from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:71:in `define_attribute_methods'
- from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:242:in `method_missing'
- from (irb):28
- >>
Add Comment
Please, Sign In to add comment