Skip to content

Instantly share code, notes, and snippets.

@StasKoval
Created June 17, 2014 11:05
Show Gist options
  • Save StasKoval/5b6fedc9c3ca0e54e640 to your computer and use it in GitHub Desktop.
Save StasKoval/5b6fedc9c3ca0e54e640 to your computer and use it in GitHub Desktop.
class Permission < ActiveRecord::Base
serialize :metadata, Hash
#bitmask :some_attribute, :as => [:value1, :value2]
attr_accessible :action, :role, :subject_class , :metadata
rails_admin do
configure :block, :metadata
end
# rails_admin do
# edit do
# field :some_attribute, :enum do
#
#=begin
# enum_method do
# :some_attribute
# end
#=end
#
# enum do
# binding.pry
# Hash[abstract_model.model.bitmasks[:some_attribute].map { |k,v| [k.humanize.titleize, v] }]
# end
#
# pretty_value do
# bindings[:object].send(name).map{|v| v.to_s.humanize.titleize }.join(', ')
# end
#
# def form_value
# bindings[:object].send(name)
# end
#
# # set this to true for multi-select
# multiple do
# true
# end
#
# end
#
# end
#
# end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment