Skip to content

Instantly share code, notes, and snippets.

@fiftin
Created September 14, 2015 04:11
Show Gist options
  • Save fiftin/5cad314f033c7aa003ec to your computer and use it in GitHub Desktop.
Save fiftin/5cad314f033c7aa003ec to your computer and use it in GitHub Desktop.
Add image to model the example of Spree taxon model
class AddBackgroundToSpreeTaxons < ActiveRecord::Migration
def change
add_column :spree_taxons, :background_file_name, :string
add_column :spree_taxons, :background_content_type, :string
add_column :spree_taxons, :background_file_size, :integer
add_column :spree_taxons, :background_updated_at, :timestamp
end
end
Spree::Taxon.class_eval do
has_attached_file :background,
styles: { large: '300x300>' },
default_style: :large,
url: '/spree/taxons/:id/:style/:basename.:extension',
path: ':rails_root/public/spree/taxons/:id/:style/:basename.:extension',
default_url: 'default_taxon_background.png'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment