Sha256: a726609860627305778ab703e1237fca9b5ed7da13dc52c57bd502cb1960beb6

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

# encoding: UTF-8

namespace :activeadmin do
  namespace :settings do
    desc "Create default admin user"
    task :create_admin => :environment do
      AdminUser.create :email => 'admin@example.com', :password => 'password', :password_confirmation => 'password'
      puts "New admin user created:
              email: admin@example.com
              password: password"
    end

    desc "Add missing settings from activeadmin_settings.yml file to the db"
    task :add => :environment do
      ActiveadminSettings.all_settings.each_key do |name|
        puts "Add setting: #{name}"
        s = ActiveadminSettings::Setting.find_or_create_by(name: name)
        
        # Save default text values to db,
        # as this way it's more easy to edit them
        if s.type == "text"
          s.string = s.default_value
          s.save
        end
      end
    end

    desc "Add settings from activeadmin_settings.yml file to the db"
    task :flush => :environment do
      ActiveadminSettings::Setting.all.destroy
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activeadmin-settings-0.2.7 lib/tasks/activeadmin_settings.rake
activeadmin-settings-0.2.6 lib/tasks/activeadmin_settings.rake