Module: Cropper::Schema::Statements
- Defined in:
- lib/cropper/schema.rb
Instance Method Summary collapse
- #add_upload(table_name, *attachment_names) ⇒ Object
- #remove_upload(table_name, *attachment_names) ⇒ Object
Instance Method Details
#add_upload(table_name, *attachment_names) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cropper/schema.rb', line 25 def add_upload(table_name, *) raise ArgumentError, "Please specify attachment name in your add_upload call in your migration." if .empty? .each do || UPLOAD_COLUMNS.each_pair do |column_name, column_type| unless column_exists? table_name, "#{}_#{column_name}" add_column(table_name, "#{}_#{column_name}", column_type) end end end end |
#remove_upload(table_name, *attachment_names) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/cropper/schema.rb', line 38 def remove_upload(table_name, *) raise ArgumentError, "Please specify attachment name in your remove_upload call in your migration." if .empty? .each do || COLUMNS.each_pair do |column_name, column_type| if column_exists? table_name, "#{}_#{column_name}" remove_column(table_name, "#{}_#{column_name}") end end end end |