I want to enable my users to switch between bootstrap-wysihtml5-rails and wysiwyg-rails (Froala) editors depending on model setting. But I cannot access bindings[:object] outside of field block. Does anyone have suggestions?
I am using Rails 4.1.14 with RailsAdmin 0.8.1. I thank you in advance for any advice.
class MyModel
include Mongoid::Document
field :body, type: String
field :body_editor
extend Enumerize
enumerize :body_editor, in: [:froala, :wysihtml5]
rails_admin do
edit do
# this causes error undefined method `[]' for nil:NilClass
if bindings[:object].body_editor == :wysihtml5
field :body, :wysihtml5 do
config_options toolbar: { fa: true, html: true, color: true } end
else
field :body, :froala do
config_options do
...
end
end
end
end
end
end
I want to enable my users to switch between bootstrap-wysihtml5-rails and wysiwyg-rails (Froala) editors depending on model setting. But I cannot access bindings[:object] outside of field block. Does anyone have suggestions?
I am using Rails 4.1.14 with RailsAdmin 0.8.1. I thank you in advance for any advice.