Skip to content

Instantly share code, notes, and snippets.

@corbanbrook
Created April 11, 2013 19:05
Show Gist options
  • Select an option

  • Save corbanbrook/5366263 to your computer and use it in GitHub Desktop.

Select an option

Save corbanbrook/5366263 to your computer and use it in GitHub Desktop.
class SoftchoiceAddAnalyticsScript < PresslyMigrator::Seed
def self.up
account = Account.where(uid: 'softchoice').first
file_path = PresslyDashboard.root.join('db/scripts/softchoice/msgapp.js')
source = File.read(file_path)
if account && (site = account.sites.where(uid: 'link').first)
# install analytics script for both apps
site.apps.each do |app|
Property::Script.create!({
app: app,
name: 'msgapp',
type: 'js',
source: source,
category: 'plugin'
})
end
end
end
def self.down
account = Account.where(uid: 'softchoice').first
if account && (site = account.sites.where(uid: 'link').first)
site.apps.each do |app|
if (script = Property::Script.where(app: app, name: 'msgapp').first)
script.destroy
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment