Class: Gluttonberg::Admin::Content::AutoSaveController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- BaseController
- Gluttonberg::Admin::Content::AutoSaveController
- Defined in:
- app/controllers/gluttonberg/admin/content/auto_save_controller.rb
Overview
this controllers saves json dump of admin forms. javascript sends an ajax calls for saving draft version in autosave table for recovery purpose
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/controllers/gluttonberg/admin/content/auto_save_controller.rb', line 11 def create auto_save = AutoSave.where(prepare_opts).first_or_initialize auto_save.data = params[AutoSave.param_name_for(params[:model_name])].to_json status = auto_save.save fix_created_at_date_for_versions(auto_save) render( :json => ( status ? "OK" : "Error").to_json ) end |
#destroy ⇒ Object
create
19 20 21 22 23 |
# File 'app/controllers/gluttonberg/admin/content/auto_save_controller.rb', line 19 def destroy status = false status = @auto_save.destroy unless @auto_save.blank? render( :json => (status ? "OK" : "Error").to_json ) end |
#retreive_changes ⇒ Object
25 26 27 |
# File 'app/controllers/gluttonberg/admin/content/auto_save_controller.rb', line 25 def retreive_changes render( :json => (@auto_save.blank? ? {} : JSON.parse(@auto_save.data).to_json ) ) end |