Module: Attachable::ClassMethods
- Defined in:
- lib/attachable.rb
Instance Method Summary collapse
-
#attachable(options = {}) ⇒ Object
Loads the attachable methods, scope, and config into the model.
Instance Method Details
#attachable(options = {}) ⇒ Object
Loads the attachable methods, scope, and config into the model.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/attachable.rb', line 12 def attachable( = {}) # Store the default prefix for file data # Defaults to "file" cattr_accessor :attachment_file_prefix self. = ([:file_prefix] || :file).to_s # Setup the default scope so the file data isn't included by default. # Generate the default scope, which includes every column except for the data column. # We use this so queries, by default, don't include the file data which could be quite large. default_scope { select(column_names.reject { |n| n == "#{}_data" }.collect {|n| "#{table_name}.#{n}" }.join(',')) } # Include all the important stuff include InstanceMethods end |