Sha256: af493f15cac0b9b18d93b12ee86c161c186aa31875d2b3723a3a5c937bf8b68a

Contents?: true

Size: 1.29 KB

Versions: 8

Compression:

Stored size: 1.29 KB

Contents

require "rails_admin_featured_content/engine"

module RailsAdminFeaturedContent
end

require 'rails_admin/config/actions'

module RailsAdmin
  module Config
    module Actions
      class FeaturedContent < Base
        RailsAdmin::Config::Actions.register(self)
        register_instance_option :member do
          true
        end

        register_instance_option :link_icon do
          'icon-align-justify'
        end

        register_instance_option :http_methods do
          [:get, :post]
        end

        register_instance_option :controller do
          Proc.new do
            @object = @abstract_model.model.find(params[:id])
            @response = {}

            if request.post?
              if params.present?

                if params[:publish]
                  status = true
                elsif params[:unpublish]
                  status = false
                elsif params[:save]
                  status = @object.status
                end

                if @object.update(content: params[:content], status: status)
                  flash[:success] = "Sucesso"
                else
                  flash[:error] = "Erro"
                end
              end
            end

            render :action => @action.template_name
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rails_admin_featured_content-1.2.3 lib/rails_admin_featured_content.rb
rails_admin_featured_content-1.2.2 lib/rails_admin_featured_content.rb
rails_admin_featured_content-1.2.1 lib/rails_admin_featured_content.rb
rails_admin_featured_content-1.1.0 lib/rails_admin_featured_content.rb
rails_admin_featured_content-1.0.6 lib/rails_admin_featured_content.rb
rails_admin_featured_content-1.0.5 lib/rails_admin_featured_content.rb
rails_admin_featured_content-1.0.4 lib/rails_admin_featured_content.rb
rails_admin_featured_content-1.0.3 lib/rails_admin_featured_content.rb