Class: EditableComponents::BlocksController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- EditableComponents::BlocksController
- Defined in:
- app/controllers/editable_components/blocks_controller.rb
Instance Method Summary collapse
Instance Method Details
#publish ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/editable_components/blocks_controller.rb', line 5 def publish model = params[:container].camelcase.constantize rescue nil if model && model.ancestors.include?( EditableComponents::Concerns::Editable ) container = model.find params[:container_id] ver = EditableComponents.publish( container, params[:version] ) respond_to do |format| # format.html { redirect_to page_path( @page, version: ver ), notice: "Version: #{ver}" } format.html { redirect_back fallback_location: '/', notice: "Version: #{ver}" } format.json { render json: { status: :ok }, status: :ok } # , location: container end end # TODO: set errors if not a valid model end |
#update ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/editable_components/blocks_controller.rb', line 19 def update model = params[:container].camelcase.constantize rescue nil if model && model.ancestors.include?( EditableComponents::Concerns::Editable ) container = model.find params[:container_id] respond_to do |format| if EditableComponents.update( container, params ) format.html { redirect_back fallback_location: '/', notice: 'Saved.' } format.json { render json: { status: :ok }, status: :ok } # , location: container else format.html { redirect_back fallback_location: '/', notice: container.errors.[:base].join( ' - ' ) } format.json { render json: container.errors, status: :unprocessable_entity } end end end # TODO: set errors if not a valid model end |