Skip to content

borgand/hide_attributes

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

No packages published

Languages