Module: SchemaAssociations::ActiveRecord::Base::ClassMethods
- Defined in:
- lib/schema_associations/active_record/associations.rb
Instance Method Summary collapse
-
#_reflect_on_association(*args) ⇒ Object
introduced in rails 4.1.
- #define_attribute_methods(*args) ⇒ Object
- #reflect_on_all_associations(*args) ⇒ Object
- #reflect_on_association(*args) ⇒ Object
-
#schema_associations(opts = {}) ⇒ Object
Per-model override of Config options.
-
#schema_associations_config ⇒ Object
:nodoc:.
Instance Method Details
#_reflect_on_association(*args) ⇒ Object
introduced in rails 4.1
24 25 26 27 |
# File 'lib/schema_associations/active_record/associations.rb', line 24 def _reflect_on_association(*args) _load_schema_associations_associations super end |
#define_attribute_methods(*args) ⇒ Object
34 35 36 37 |
# File 'lib/schema_associations/active_record/associations.rb', line 34 def define_attribute_methods(*args) super _load_schema_associations_associations end |
#reflect_on_all_associations(*args) ⇒ Object
29 30 31 32 |
# File 'lib/schema_associations/active_record/associations.rb', line 29 def reflect_on_all_associations(*args) _load_schema_associations_associations super end |
#reflect_on_association(*args) ⇒ Object
18 19 20 21 |
# File 'lib/schema_associations/active_record/associations.rb', line 18 def reflect_on_association(*args) _load_schema_associations_associations super end |
#schema_associations(opts = {}) ⇒ Object
Per-model override of Config options. Use via, e.g.
class MyModel < ActiveRecord::Base
schema_associations :auto_create => false
end
If :auto_create
is not specified, it is implicitly specified as true. This allows the “non-invasive” style of using SchemaAssociations in which you set the global Config to auto_create = false
, then in any model that you want auto associations you simply do:
class MyModel < ActiveRecord::Base
schema_associations
end
Of course other options can be passed, such as
class MyModel < ActiveRecord::Base
schema_associations :concise_names => false, :except_type => :has_and_belongs_to_many
end
61 62 63 |
# File 'lib/schema_associations/active_record/associations.rb', line 61 def schema_associations(opts={}) @schema_associations_config = SchemaAssociations.config.merge({:auto_create => true}.merge(opts)) end |
#schema_associations_config ⇒ Object
:nodoc:
65 66 67 |
# File 'lib/schema_associations/active_record/associations.rb', line 65 def schema_associations_config # :nodoc: @schema_associations_config ||= SchemaAssociations.config.dup end |