Class: CMS::ViewablesController
- Inherits:
-
Object
- Object
- CMS::ViewablesController
- Defined in:
- app/controllers/cms/viewables_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
used by the add viewable link.
-
#update ⇒ Object
used by [data-js-cms-sortable] element to modify the viewable position within the list.
Instance Method Details
#create ⇒ Object
used by the add viewable link
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/cms/viewables_controller.rb', line 6 def create current_count = UniqueKey.where(list_key_params).count if params[:max] == 'Infinity' || current_count < params[:max].to_i unique_key = list_key_params.merge(position: current_count + 1) viewable = UniqueKey.create_localized_viewable!(unique_key) if unique_key[:viewable_type] != 'Viewable::Block' path = rails_admin.edit_path(model_name: unique_key[:viewable_type].to_s.underscore.gsub('/', '~'), id: viewable.id) redirect_to path else redirect_to :back end else redirect_to :back end end |
#update ⇒ Object
used by [data-js-cms-sortable] element to modify the viewable position within the list
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/cms/viewables_controller.rb', line 27 def update unique_key = UniqueKey.find(params[:id]) if unique_key.update(unique_key_params) flash_now!(:success) else flash_now!(error: unique_key.errors..first) end respond_to do |format| format.js {} end end |