ReloadAttribute
This is a RubyGem for Rails/ActiveRecord models to allow updating a model instance's attributes from the database.
Installation
Add this line to your application's Gemfile:
gem 'reload-attribute'
And then execute:
$ bundle
Or install it yourself as:
$ gem install reload-attribute
Usage
widget = Widget.find(123)
#=> #<Widget id: 123, foo: "foo_original", bar: "bar_original">
Widget.find(123)
#=> #<Widget id: 123, foo: "foo_updated", bar: "bar_updated">
widget
#=> #<Widget id: 123, foo: "foo_original", bar: "bar_original">
widget.reload_attribute(:foo, :bar)
#=> { foo: "foo_updated", bar: "bar_updated" }
widget
#=> #<Widget id: 123, foo: "foo_updated", bar: "bar_updated">
License
The gem is available as open source under the terms of the MIT License.