Skip to content

Instantly share code, notes, and snippets.

@macedo
Created October 1, 2012 13:12
Show Gist options
  • Save macedo/3811717 to your computer and use it in GitHub Desktop.
Save macedo/3811717 to your computer and use it in GitHub Desktop.
Get model accessible attributes
class ActiveRecord::Base
def accessible_attributes
accessible_attributes = self.class.accessible_attributes.select do |attr|
!attr.blank?
end
attributes.slice(*accessible_attributes)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment