Skip to content

Instantly share code, notes, and snippets.

@denniskuczynski
Created May 9, 2012 15:14
Show Gist options
  • Save denniskuczynski/2645360 to your computer and use it in GitHub Desktop.
Save denniskuczynski/2645360 to your computer and use it in GitHub Desktop.
Example of updating a Rails Model attribute in place
it "tries to update a Model's string attribute in place" do
person = Person.new
person.name = ""
person.save!
person.reload
person.name = ""
person.name << "TEST"
person.save!
person.reload
person.name.should eq("")
person.name = ""
person.name_will_change!
person.name << "TEST"
person.save!
person.reload
person.name.should eq("TEST")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment