Last active
December 11, 2015 10:48
-
-
Save costa/4589368 to your computer and use it in GitHub Desktop.
a model object's attributes stripper (for use in Rails 3.2+ controller specs), a place to put this: spec/support/accessible_attributes.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def accessible_attributes(obj, role = :default) | |
HashWithIndifferentAccess.new(obj.attributes.slice(*obj.class.attr_accessible[role].to_a)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment