Class: Caboose::PageBlockFieldValuesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Caboose::PageBlockFieldValuesController
- Defined in:
- app/controllers/caboose/page_block_field_values_controller.rb
Instance Method Summary collapse
-
#admin_update ⇒ Object
PUT /admin/page-block-field-values/:id.
-
#admin_update_file ⇒ Object
POST /admin/page-block-field-values/:id/file.
-
#admin_update_image ⇒ Object
POST /admin/page-block-field-values/:id/image.
Methods inherited from ApplicationController
#before_action, #before_before_action, #logged_in?, #logged_in_user, #login_user, #logout_user, #parse_url_params, #reject_param, #user_is_allowed, #user_is_allowed_to, #validate_cookie, #validate_token, #var, #verify_logged_in
Instance Method Details
#admin_update ⇒ Object
PUT /admin/page-block-field-values/:id
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/caboose/page_block_field_values_controller.rb', line 6 def admin_update return unless user_is_allowed('pages', 'edit') resp = StdClass.new({'attributes' => {}}) fv = PageBlockFieldValue.find(params[:id]) save = true user = logged_in_user params.each do |k,v| case k when 'value' fv.value = v end end resp.success = save && fv.save render :json => resp end |
#admin_update_file ⇒ Object
POST /admin/page-block-field-values/:id/file
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/caboose/page_block_field_values_controller.rb', line 41 def admin_update_file return unless user_is_allowed('pages', 'edit') resp = StdClass.new({'attributes' => {}}) fv = PageBlockFieldValue.find(params[:id]) fv.file = params[:value] fv.save resp.success = true resp.attributes = { 'value' => { 'value' => fv.file.url }} render :json => resp end |
#admin_update_image ⇒ Object
POST /admin/page-block-field-values/:id/image
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/caboose/page_block_field_values_controller.rb', line 27 def admin_update_image return unless user_is_allowed('pages', 'edit') resp = StdClass.new({'attributes' => {}}) fv = PageBlockFieldValue.find(params[:id]) fv.image = params[:value] fv.save resp.success = true resp.attributes = { 'value' => { 'value' => fv.image.url(:tiny) }} render :json => resp end |