Whats the alternative syntax for ActiveRecord::RecordNotFound in Rails 3
With the introduction of ActiveModel i开发者_如何学Cn Rails 3 whats the new method of calling ActiveRecord::RecordNotFound. ActiveModel::RecordNotFound ?
This is the definition (1) of ActiveModel:
ActiveModel is a class to be implemented by each ORM to allow Rails to generate customized controller code.
ActiveRecord implements ActiveModel. ActiveRecord raises its ActiveRecord::RecordNotFound exception when it can't find record by given id or a set of ids (2) in the database.
This mean there can't be such exception like ActiveModel::RecordNotFound.
ActiveModel is a set of modules and conventions to be implemented, the main goal being providing a common interface to mappers, no more, no less. So nope, ActiveRecord::RecordNotFound
stays ActiveRecord::RecordNotFound
. RecordNotFound
does not make sense for every mapper : with Mongoid for instance, you'll have DocumentNotFound
(well, Mongoid::Errors::DocumentNotFound
).
精彩评论