Removed unused acts_as_configurable gem.

This commit is contained in:
Benjamin Meichsner 2013-09-02 10:03:12 +02:00
parent 3e4c535bb1
commit 4ea940e4a3
4 changed files with 38 additions and 50 deletions

View File

@ -70,8 +70,4 @@ group :development do
#gem 'common_deploy', require: false, path: '../../common_deploy' # pending foodcoops/foodsoft#34, git: 'git://github.com/fsmanuel/common_deploy.git' #gem 'common_deploy', require: false, path: '../../common_deploy' # pending foodcoops/foodsoft#34, git: 'git://github.com/fsmanuel/common_deploy.git'
# Avoid having content-length warnings # Avoid having content-length warnings
gem 'thin' gem 'thin'
end end
# Gems left for backwards compatibility
gem 'acts_as_configurable', git: 'git://github.com/bwalding/acts_as_configurable.git' # user settings migration needs it

View File

@ -4,13 +4,6 @@ GIT
specs: specs:
localize_input (0.1.0) localize_input (0.1.0)
GIT
remote: git://github.com/bwalding/acts_as_configurable.git
revision: cdf6f6f979019275b523d10684b748f08e2dd8e8
specs:
acts_as_configurable (0.0.1)
rake
GIT GIT
remote: git://github.com/technoweenie/acts_as_versioned.git remote: git://github.com/technoweenie/acts_as_versioned.git
revision: 63b1fc8529d028fae632fe80ec0cb25df56cd76b revision: 63b1fc8529d028fae632fe80ec0cb25df56cd76b
@ -263,7 +256,6 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
acts_as_configurable!
acts_as_tree acts_as_tree
acts_as_versioned! acts_as_versioned!
better_errors better_errors

View File

@ -1,34 +1,46 @@
class MigrateUserSettings < ActiveRecord::Migration class MigrateUserSettings < ActiveRecord::Migration
def up def up
old_settings = ConfigurableSetting.all say_with_time 'Save old user settings in new RailsSettings module' do
old_settings = ConfigurableSetting.all
old_settings.each do |old_setting|
# get target (user) old_settings.each do |old_setting|
type = old_setting.configurable_type # get target (user)
id = old_setting.configurable_id type = old_setting.configurable_type
user = type.constantize.find(id) id = old_setting.configurable_id
begin
# get the data (settings) user = type.constantize.find(id)
name = old_setting.name rescue ActiveRecord::RecordNotFound
namespace = name.split('.')[0] Rails.logger.debug "Can't find configurable object with type: #{type.inspect}, id: #{id.inspect}"
key = name.split('.')[1].underscore # Camelcase to underscore next
end
# prepare value
value = YAML.load(old_setting.value) # get the data (settings)
value = value.nil? ? false : value name = old_setting.name
namespace = name.split('.')[0]
# set the settings_attributes (thanks to settings.merge! we can set them one by one) key = name.split('.')[1].underscore # Camelcase to underscore
user.settings_attributes = {
"#{namespace}" => { # prepare value
"#{key}" => value value = YAML.load(old_setting.value)
value = value.nil? ? false : value
# set the settings_attributes (thanks to settings.merge! we can set them one by one)
user.settings_attributes = {
"#{namespace}" => {
"#{key}" => value
}
} }
}
# save the user to apply after_save callback
# save the user to apply after_save callback user.save
user.save end
end end
drop_table :configurable_settings
end end
def down def down
end end
end end
# this is the base class of all configurable settings
class ConfigurableSetting < ActiveRecord::Base; end

View File

@ -66,18 +66,6 @@ ActiveRecord::Schema.define(:version => 20130718183101) do
add_index "assignments", ["user_id", "task_id"], :name => "index_assignments_on_user_id_and_task_id", :unique => true add_index "assignments", ["user_id", "task_id"], :name => "index_assignments_on_user_id_and_task_id", :unique => true
create_table "configurable_settings", :force => true do |t|
t.integer "configurable_id"
t.string "configurable_type"
t.integer "targetable_id"
t.string "targetable_type"
t.string "name", :default => "", :null => false
t.string "value_type"
t.text "value"
end
add_index "configurable_settings", ["name"], :name => "index_configurable_settings_on_name"
create_table "deliveries", :force => true do |t| create_table "deliveries", :force => true do |t|
t.integer "supplier_id" t.integer "supplier_id"
t.date "delivered_on" t.date "delivered_on"