Sha256: 78b66274eef9b5934a9244cb19d69a60384f179659d2595d5072b2315e15f35c

Contents?: true

Size: 685 Bytes

Versions: 7

Compression:

Stored size: 685 Bytes

Contents

module Controller
  module ActsAsPublishedConcern
    extend ActiveSupport::Concern

    def toggle_published
      @resource = load_resource
      @resource.toggle_published!

      action_taken = @resource.published? ? 'published' : 'unpublished'
      resource_label = @resource.try_all(*Itsf::Backend::Configuration.resource_title_methods)
      if Rails.version < '5.0.0'
        redirect_to :back, notice: I18n.t("acts_as_published.notices.#{action_taken}", name: resource_label)
      else
        flash[:notice] = I18n.t("acts_as_published.notices.#{action_taken}", name: resource_label)
        redirect_back(fallback_location: main_app.root_path)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
itsf_backend-4.2.3 app/controllers/concerns/controller/acts_as_published_concern.rb
itsf_backend-4.2.2 app/controllers/concerns/controller/acts_as_published_concern.rb
itsf_backend-4.2.1 app/controllers/concerns/controller/acts_as_published_concern.rb
itsf_backend-4.2.0 app/controllers/concerns/controller/acts_as_published_concern.rb
itsf_backend-4.0.1 app/controllers/concerns/controller/acts_as_published_concern.rb
itsf_backend-4.0.0 app/controllers/concerns/controller/acts_as_published_concern.rb
itsf_backend-3.1.1 app/controllers/concerns/controller/acts_as_published_concern.rb