This repository was archived by the owner on Jan 8, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Hides ActiveRecord attributes such as 'password' etc from being exposed via 'to_json' and 'to_xml'.
License
borgand/hide_attributes
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
= 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 (c) 2011 Laas Toom, released under the MIT license
About
Hides ActiveRecord attributes such as 'password' etc from being exposed via 'to_json' and 'to_xml'.
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published