Sha256: 8e9d486ab32fcbaaadf7e96ccc58f8b94f12245bdd994ee698a2f003cf18c346

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

# This migration comes from spree (originally 20140309033438)
class CreateStoreFromPreferences < ActiveRecord::Migration
  class Store < ActiveRecord::Base
    self.table_name = 'spree_stores'
  end
  def change
    preference_store = Spree::Preferences::Store.instance
    if store = Store.where(default: true).first
      store.meta_description = preference_store.get('spree/app_configuration/default_meta_description') {}
      store.meta_keywords    = preference_store.get('spree/app_configuration/default_meta_keywords') {}
      store.seo_title        = preference_store.get('spree/app_configuration/default_seo_title') {}
      store.save!
    else
      # we set defaults for the things we now require
      Store.new do |s|
        s.name              = preference_store.get 'spree/app_configuration/site_name' do
          'Sample Store'
        end
        s.url               = preference_store.get 'spree/app_configuration/site_url' do
          'example.com'
        end
        s.mail_from_address = preference_store.get 'spree/app_configuration/mails_from' do
          'store@example.com'
        end

        s.meta_description = preference_store.get('spree/app_configuration/default_meta_description') {}
        s.meta_keywords    = preference_store.get('spree/app_configuration/default_meta_keywords') {}
        s.seo_title        = preference_store.get('spree/app_configuration/default_seo_title') {}
        s.default_currency = preference_store.get('spree/app_configuration/currency') {}
        s.code             = 'spree'
      end.save!
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_order_reporting-0.0.2 spec/dummy/db/migrate/20160707103486_create_store_from_preferences.spree.rb
spree_order_reporting-0.0.1 spec/dummy/db/migrate/20160706112438_create_store_from_preferences.spree.rb