Module: Litesearch::Model::ActiveRecordSchemaMethods
- Defined in:
- lib/litestack/litesearch/model.rb
Instance Attribute Summary collapse
-
#model_class ⇒ Object
Returns the value of attribute model_class.
Instance Method Summary collapse
Instance Attribute Details
#model_class ⇒ Object
Returns the value of attribute model_class.
139 140 141 |
# File 'lib/litestack/litesearch/model.rb', line 139 def model_class @model_class end |
Instance Method Details
#allowed_attributes ⇒ Object
157 158 159 |
# File 'lib/litestack/litesearch/model.rb', line 157 def allowed_attributes super + [:polymorphic, :as, :action_text] end |
#field(name, attributes = {}) ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/litestack/litesearch/model.rb', line 141 def field(name, attributes = {}) keys = attributes.keys if keys.include?(:action_text) || keys.include?(:rich_text) attributes[:source] = "#{ActionText::RichText.table_name}.body" rescue "action_text_rich_texts.body" attributes[:reference] = :record_id attributes[:conditions] = { record_type: model_class.name } attributes[:target] = nil elsif keys.include? :as attributes[:source] = attributes[:target] unless attributes[:source] attributes[:reference] = "#{attributes[:as]}_id" attributes[:conditions] = {"#{attributes[:as]}_type".to_sym => model_class.name } attributes[:target] = nil end super(name, attributes) end |