Exception: HumanError::Errors::AssociationError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- HumanError::Errors::AssociationError
- Includes:
- HumanError::Error, CrudError
- Defined in:
- lib/human_error/errors/crud_errors/association_error.rb
Instance Attribute Summary collapse
-
#association_id ⇒ Object
Returns the value of attribute association_id.
-
#association_name ⇒ Object
Returns the value of attribute association_name.
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Attributes included from CrudError
#action, #resource_id, #resource_name
Attributes included from HumanError::Error
#code, #developer_documentation_url, #external_documentation_url, #id, #message
Class Method Summary collapse
Instance Method Summary collapse
Methods included from CrudError
Methods included from HumanError::Error
#as_json, included, #initialize, #to_json, #to_s
Instance Attribute Details
#association_id ⇒ Object
Returns the value of attribute association_id.
9 10 11 |
# File 'lib/human_error/errors/crud_errors/association_error.rb', line 9 def association_id @association_id end |
#association_name ⇒ Object
Returns the value of attribute association_name.
9 10 11 |
# File 'lib/human_error/errors/crud_errors/association_error.rb', line 9 def association_name @association_name end |
#attributes ⇒ Object
Returns the value of attribute attributes.
9 10 11 |
# File 'lib/human_error/errors/crud_errors/association_error.rb', line 9 def attributes @attributes end |
Class Method Details
.convert(original_error, overrides = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/human_error/errors/crud_errors/association_error.rb', line 13 def self.convert(original_error, overrides = {}) initialization_parameters = {} case original_error.class.name when 'ActiveRecord::InvalidForeignKey' = /DETAIL: Key \((.*)_id\)=\(([a-f0-9\-]+)\)/ = original_error. . match()[1..-1] initialization_parameters = { association_name: [0], association_id: [1], } end new(initialization_parameters.merge(overrides)) end |
Instance Method Details
#detail ⇒ Object
40 41 42 43 |
# File 'lib/human_error/errors/crud_errors/association_error.rb', line 40 def detail "The #{association_name} that you attempted to associate with " \ "the #{resource_name} was not valid." end |
#http_status ⇒ Object
32 33 34 |
# File 'lib/human_error/errors/crud_errors/association_error.rb', line 32 def http_status 422 end |
#source ⇒ Object
45 46 47 48 49 50 |
# File 'lib/human_error/errors/crud_errors/association_error.rb', line 45 def source { resource_name => attributes, "#{association_name} id" => association_id, } end |
#title ⇒ Object
36 37 38 |
# File 'lib/human_error/errors/crud_errors/association_error.rb', line 36 def title 'Association Error' end |