Active Resource Changeable

As ActiveRecord provides you to get all the changes of your unsaved object, active_resource_changeable gem also serves the same purpose by calling its changes method.


Add this line to your application's Gemfile:

gem 'active_resource_changeable'

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_resource_changeable


include ActiveResourceChangeable

into your model and then you can call changes method on its objects. For example.

class User < ActiveResource::Base = ""

  include ActiveResourceChangeable


user = User.find(1)
user.firstname = "Neeraj1"
user.lastname = "Kumar1" = ""
user.username = "neeraj1"

user.changes = {"firstname"=>["Neeraj", "Neeraj1"], "lastname"=>["Kumar", "Kumar1"], "username=>["neeraj", "neeraj1], "email"=>["", ""]}

ActiveResourceChangeable works for nested ActiveResource objects too and gives the result something like

{"companyName"=>["Skipped Levels 034", "ABC Company"],
 "address"=>{""=>{"line1"=>["1234 Skipped Levels 034", "line1"]}, "countryType"=>{"code"=>["DEU", "IND"]}},
 "countryType"=>{""=>{"code"=>["DEU", "IND"]}},
 "statusType"=>{""=>{"code"=>["A", "B"]}}}


After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Similar Articles

Ruby-oci8 with Rails
Successful Migration from svn to git with history
Smart Deployment using Hubot
Roda versus Rails
Active Resource Changeable

blog comments powered by Disqus