Skip to content

Instantly share code, notes, and snippets.

@psy-q
Created January 2, 2012 14:34
Show Gist options
  • Select an option

  • Save psy-q/1550897 to your computer and use it in GitHub Desktop.

Select an option

Save psy-q/1550897 to your computer and use it in GitHub Desktop.
Loading development environment (Rails 3.1.1)
pry(main)> wb = ShippingCalculators::WeightBased.new
=> #<ShippingCalculators::WeightBased:0x64bcf5c>
pry(main)> wb.inspect
NoMethodError: undefined method `has_key?' for nil:NilClass
from /home/rca/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/whiny_nil.rb:48:in `method_missing'
pry(main)> wb.name = "foo"
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.delete
from /home/rca/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/active_record/attribute_methods/write.rb:28:in `write_attribute'
pry(main)> wb.save
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.delete
from /home/rca/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/active_record/transactions.rb:336:in `restore_transaction_record_state'
pry(main)>
--- and now with the plain one ----
pry(main)> sc = ShippingCalculators::ShippingCalculator.new
=> #<ShippingCalculators::ShippingCalculator:0x64619f4>
pry(main)> sc.name = "foo"
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.delete
from /home/rca/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/active_record/attribute_methods/write.rb:28:in `write_attribute'
pry(main)> sc.save
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.delete
from /home/rca/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/active_record/transactions.rb:336:in `restore_transaction_record_state'
pry(main)> sc.inspect
NoMethodError: undefined method `has_key?' for nil:NilClass
from /home/rca/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/whiny_nil.rb:48:in `method_missing'
-- the table names --
pry(main)> ShippingCalculators::ShippingCalculator.table_name
=> "shipping_calculators"
pry(main)> ShippingCalculators::WeightBased.table_name
=> "shipping_calculators"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment