end
def update
- if @object.update_attributes params[@object.class.to_s.underscore.singularize.to_sym]
+ updates = params[@object.class.to_s.underscore.singularize.to_sym]
+ updates.keys.each do |attr|
+ if @object.send(attr).is_a? Hash and updates[attr].is_a? String
+ updates[attr] = Oj.load updates[attr]
+ end
+ end
+ if @object.update_attributes updates
show
else
self.render_error status: 422
input_type = 'text'
end
+ attrvalue = attrvalue.to_json if attrvalue.is_a? Hash
+
link_to attrvalue.to_s, '#', {
"data-emptytext" => "none",
"data-placement" => "bottom",
"data-type" => input_type,
"data-resource" => object.class.to_s.underscore,
"data-name" => attr,
- "data-value" => object.send(attr),
"data-url" => url_for(action: "update", id: object.uuid, controller: object.class.to_s.pluralize.underscore),
"data-original-title" => "Update #{attr.gsub '_', ' '}",
:class => "editable"