HideAttributes
This plugin generates wrappers to ‘to_xml` and `to_json` methods to automatically exclude attributes such as passwords from output.
Example
To auto-hide password fields from generated JSON output, add this to your model:
class User < ActiveRecord::Base
hide_attributes :password, :password_salt
end
Then use as usual:
user = User.first
# Output user's JSON without hidden attributes present
user.to_json
# Temporarly override hiding and output all attributes
user.to_json :except => nil
INSTALL
To install simply add it to your Gemfile
gem 'hide_attributes'
And run bundle:
bundle install
Requirements
Runtime requirements are:
-
ActiveRecord >=3.0
TODO
-
Write tests
Copyright © 2011 Laas Toom, released under the MIT license