Sha256: a67338b40cce0f38ff32999d179984e8b537b0eb4a645300100d9d66722e4ac2

Contents?: true

Size: 1.01 KB

Versions: 10

Compression:

Stored size: 1.01 KB

Contents

module Concerns
  module Backend
    module ContentTypeController
      extend ActiveSupport::Concern

      included do
        layout 'backend/lightbox'
        before_action :find_model
        helper_method :content_path
      end

      module ClassMethods
        def model(value)
          define_method(:model) { value }
        end

        def allowed_params(*args)
          define_method(:allowed_params) do
            params.require(model.name.tableize.singularize).permit(*args)
          end
        end
      end

      def find_model
        @model = model.find(params[:id]).decorate
      end

      def content_path
        column = @model.column
        path = "edit_translation_backend_#{column.row.rowable.class.to_s.downcase}_path"
        send(path, column.row.rowable, locale, anchor: "content-row-#{column.row.id}")
      end

      def update
        if @model.update_attributes allowed_params
          redirect_to content_path
        else
          render :edit
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
udongo-2.0.4 app/controllers/concerns/backend/content_type_controller.rb
udongo-2.0.3 app/controllers/concerns/backend/content_type_controller.rb
udongo-2.0.2 app/controllers/concerns/backend/content_type_controller.rb
udongo-2.0.1 app/controllers/concerns/backend/content_type_controller.rb
udongo-2.0.0 app/controllers/concerns/backend/content_type_controller.rb
udongo-1.0.4 app/controllers/concerns/backend/content_type_controller.rb
udongo-1.0.3 app/controllers/concerns/backend/content_type_controller.rb
udongo-1.0.2 app/controllers/concerns/backend/content_type_controller.rb
udongo-1.0.1 app/controllers/concerns/backend/content_type_controller.rb
udongo-1.0.0 app/controllers/concerns/backend/content_type_controller.rb