Sha256: 72332a0a784cbfac0b92c072b704d36dd37f0c2a2e88f2b3f4ebee0585f23b17

Contents?: true

Size: 978 Bytes

Versions: 5

Compression:

Stored size: 978 Bytes

Contents

module Spina
  module Admin
    class ResourcesController < AdminController
      before_action :set_locale
      before_action :set_resource, only: [:show, :edit, :update]

      def show        
        add_breadcrumb @resource.label
      end

      def edit        
        add_breadcrumb @resource.label, spina.admin_resource_path(@resource)
        add_breadcrumb t('spina.edit')
      end

      def update
        if Mobility.with_locale(@locale) { @resource.update(resource_params) }
          redirect_to spina.admin_resource_path(@resource)
        else
          render :edit
        end
      end

      private

        def resource_params
          params.require(:resource).permit(:label, :slug, :view_template, :order_by, :parent_page_id)
        end

        def set_resource
          @resource = Resource.find(params[:id])          
        end

        def set_locale
          @locale = params[:locale] || I18n.default_locale
        end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spina-2.0.2 app/controllers/spina/admin/resources_controller.rb
spina-2.0.1 app/controllers/spina/admin/resources_controller.rb
spina-2.0.0 app/controllers/spina/admin/resources_controller.rb
spina-2.0.0.beta app/controllers/spina/admin/resources_controller.rb
spina-2.0.0.alpha app/controllers/spina/admin/resources_controller.rb