Created
September 14, 2015 04:11
-
-
Save fiftin/5cad314f033c7aa003ec to your computer and use it in GitHub Desktop.
Add image to model the example of Spree taxon model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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