Skip to content

Concatenation changes default value in model #6115

Description

@alexeyramazanov

Rails 3.2.3 Ruby 1.9.3.125
Example shows the problem:

create_table "settings" do |t|
  t.string   "param", :null => false
  t.text     "value", :null => false
  t.datetime "created_at"
  t.datetime "updated_at"
end

> Setting.column_defaults
 => {"id"=>nil, "param"=>nil, "value"=>"", "created_at"=>nil, "updated_at"=>nil}
> Setting.new    
 => #<Setting id: nil, param: nil, value: "", created_at: nil, updated_at: nil> 
> s = Setting.new
 => #<Setting id: nil, param: nil, value: "", created_at: nil, updated_at: nil> 
> s.value << "text" # MAGIC STARTS HERE
 => "text" 
> s
 => #<Setting id: nil, param: nil, value: "text", created_at: nil, updated_at: nil> 
> Setting.new
 => #<Setting id: nil, param: nil, value: "text", created_at: nil, updated_at: nil>
> Setting.column_defaults
 => {"id"=>nil, "param"=>nil, "value"=>"text", "created_at"=>nil, "updated_at"=>nil} 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions