Created
June 17, 2014 11:04
-
-
Save StasKoval/bc32f7fb7013246770bd to your computer and use it in GitHub Desktop.
rails admin module for serailize data
This file contains hidden or 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
require 'rails_admin/config/fields/base' | |
module RailsAdmin | |
class Metadata < RailsAdmin::Config::Fields::Base | |
RailsAdmin::Config::Fields::Types::register(self) | |
def value | |
raise 'No metadata!' unless bindings[:object].respond_to?(:metadata) | |
bindings[:object].metadata[method_name] | |
end | |
def allowed_methods | |
'metadata' | |
end | |
def parse_input(params) | |
params['metadata'] ||=bindings[:object].metadata | |
params['metadata'][method_name] = params.delete(method_name) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment