Sha256: 490919e855c894da6e487ee6f0d0fa24514cc778cfd01162db2ea4dca4897a9f

Contents?: true

Size: 1.56 KB

Versions: 35

Compression:

Stored size: 1.56 KB

Contents

module Rao
  module Component
    # Usage:
    #
    # Setup the model with acts_as_published:
    #
    #     # app/models/picture.rb
    #     class Picture < ActiveRecord::Base
    #       include ActsAsPublished::ActiveRecord
    #       acts_as_published
    #       # ...
    #     end

    # You will have to add a publishing route to your resource:
    #
    #     # config/routes.rb:
    #     Rails.application.routes do
    #       resources :picture do
    #         post :toggle_published, on: :member
    #       end
    #       # ...
    #     end
    #
    # Additionally you will need a controller action to handle the reponsitioning.
    # Include Rao::ResourcesController::ActsAsPublishedConcern from rao-resource_controller
    # if you don't want to implement it yourself:
    #
    #     # app/controllers/pictures_controller.rb
    #     class PicturesController < ApplicationController
    #       include Rao::ResourcesController::ActsAsPublishedConcern
    #       # ...
    #     end
    #
    # Use the acts_as_published_actions macro in your collection table:
    #
    #     # app/views/pictures/index.html.haml
    #     = collection_table(collection: @pictures) do |table|
    #       = table.acts_as_published_actions
    #
    module CollectionTable::ActsAsPublishedConcern
      extend ActiveSupport::Concern

      def acts_as_published_actions(options = {}, &block)
        options.reverse_merge!(render_as: :acts_as_published, title: t('.column_titles.acts_as_published'))
        column(:acts_as_published_actions, options, &block)
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
rao-component-0.0.52.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.51.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.50.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.49.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.48.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.47.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.46.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.45.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.44.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.43.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.42.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.41.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.40.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.39.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.38.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.37.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.36.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.35.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.34.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb
rao-component-0.0.33.pre app/concerns/rao/component/collection_table/acts_as_published_concern.rb