Skip to content

Instantly share code, notes, and snippets.

/user.rb Secret

Created November 14, 2014 01:08
Show Gist options
  • Save anonymous/f9b197b0a0c2e1d54a1a to your computer and use it in GitHub Desktop.
Save anonymous/f9b197b0a0c2e1d54a1a to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
string :name
def foo
name = "Bar"
end
def working_foo
self.name = "Bar"
end
end
user = User.new
user.name = "FooBar"
puts user.name # => FooBar
# This makes no change
user.foo
puts user.name # => FooBar
# This makes the change in the current instance of user
user.working_foo
puts user.name # => Bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment