Module: CustomDbDriver::CustomAssociation
- Defined in:
- lib/custom_db_driver.rb
Overview
def belongs_to(attr_name, options={})
options[:class_name] ||= attr_name.to_s.camelize
@model.class_eval do
define_method(attr_name) do
result = options[:class_name].constantize.where("id" => self.send("#{options[:class_name].underscore}_id"))
result.first
end
end
end
end
end
Defined Under Namespace
Modules: CustomDrivers
Constant Summary collapse
- AVAILABLE_DB_DRIVERS =
['my_sql', 'mongo_db']
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
39 40 41 |
# File 'lib/custom_db_driver.rb', line 39 def self.included(base) base.extend(CustomDrivers) end |