Extensions to nil which allow for more helpful error messages for people who are new to rails.
The aim is to ensure that when users pass nil to methods where that isn’t appropriate, instead of NoMethodError and the name of some method used by the framework users will see a message explaining what type of object was expected.
Methods
Constants
WHINERS | = | [ ::ActiveRecord::Base, ::Array ] |
Instance Public methods
Source: show
# File rails/activesupport/lib/active_support/whiny_nil.rb, line 21 def id raise RuntimeError, "Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id", caller end
Source: show
# File rails/actionpack/lib/action_controller/routing.rb, line 22 def to_param self end