Skip to content
Browse files

Removed default for column "value" to fix serialization issue with MySQL

Fixes #31
  • Loading branch information...
1 parent 2cf7dc0 commit 891c9ffaf401fd6c947974f7bc5aadc8eee4deaa @ledermann committed
View
5 Changelog.md
@@ -1,3 +1,8 @@
+WIP
+
+- Removed default for column "value" to fix serialization issue with MySQL
+
+
Version 2.0.1 (2013-03-08)
- Added mass assignment security by protecting all regular attributes
View
2 lib/generators/rails_settings/migration/templates/migration.rb
@@ -2,7 +2,7 @@ class RailsSettingsMigration < ActiveRecord::Migration
def self.up
create_table :settings do |t|
t.string :var, :null => false
- t.text :value, :null => false
+ t.text :value
t.references :target, :null => false, :polymorphic => true
t.timestamps
end
View
6 spec/setting_object_spec.rb
@@ -5,6 +5,12 @@
let(:new_setting_object) { user.setting_objects.build({ :var => 'dashboard'}, :without_protection => true) }
let(:saved_setting_object) { user.setting_objects.create!({ :var => 'dashboard', :value => { 'theme' => 'pink', 'filter' => true}}, :without_protection => true) }
+ describe "serialization" do
+ it "should have a hash default" do
+ RailsSettings::SettingObject.new.value.should == {}
+ end
+ end
+
describe "Getter and Setter" do
context "on unsaved settings" do
it "should respond to setters" do
View
2 spec/spec_helper.rb
@@ -59,7 +59,7 @@ def setup_db
ActiveRecord::Schema.define(:version => 1) do
create_table :settings do |t|
t.string :var, :null => false
- t.text :value, :null => false
+ t.text :value
t.references :target, :null => false, :polymorphic => true
t.timestamps
end

0 comments on commit 891c9ff

Please sign in to comment.
Something went wrong with that request. Please try again.