No release in over 3 years
Low commit activity in last 3 years
Provides ActiveRecord instances with a method to re-fetch specific attributes from the database
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

ReloadAttribute

Build Status

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.