Class: Rails::Mongoid::Railtie
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
Rails::Railtie
|
|
|
Instance Chain:
self,
Rails::Railtie
|
|
| Inherits: |
Rails::Railtie
|
| Defined in: | lib/mongoid/railtie.rb |
Overview
Hooks Mongoid into ::Rails 3 and higher.
Class Method Summary
-
.rescue_responses
Mapping of rescued exceptions to HTTP responses.
Instance Method Summary
-
#handle_configuration_error(e)
::Railsruns all initializers first before getting into any generator code, so we have no way in the initializer to know if we are generating a mongoid.yml.
Class Method Details
.rescue_responses
Mapping of rescued exceptions to HTTP responses
@ return [Hash] rescued responses
# File 'lib/mongoid/railtie.rb', line 23
def self.rescue_responses { 'Mongoid::Errors::DocumentNotFound' => :not_found, 'Mongoid::Errors::Validations' => 422 } end
Instance Method Details
#handle_configuration_error(e)
::Rails runs all initializers first before getting into any generator code, so we have no way in the initializer to know if we are generating a mongoid.yml. So instead of failing, we catch all the errors and print them out.
# File 'lib/mongoid/railtie.rb', line 95
def handle_configuration_error(e) puts 'There is a configuration error with the current mongoid.yml.' puts e. end