Sha256: 23a3243ad9a13d332c921045f3f0f592be48a0275abd4293918aa719a2df129d

Contents?: true

Size: 736 Bytes

Versions: 4

Compression:

Stored size: 736 Bytes

Contents

class Ecm::News::Backend::ItemsController < Itsf::Backend::Resource::BaseController
  def self.resource_class
    Ecm::News::Item
  end

  def toggle_published
    @resource = resource_class.find(params[:id])
    @resource.toggle_published!
    action = @resource.published? ? :published : :unpublished
    respond_with(
      @resource,
      location: collection_path,
      notice: I18n.t("flash.actions.#{action_name}.#{action}.notice", inflections)
    )
  end

  private

  def permitted_params
    params
      .require(:ecm_news_item)
      .permit(:title, :locale, :body, :link_to_more, :published, pictures_attributes: [ :image, :_destroy, :id ])
  end

  def load_resource
    load_scope.friendly.find(params[:id])
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ecm_news2_backend-1.2.1 app/controllers/ecm/news/backend/items_controller.rb
ecm_news2_backend-1.2.0 app/controllers/ecm/news/backend/items_controller.rb
ecm_news2_backend-1.1.3 app/controllers/ecm/news/backend/items_controller.rb
ecm_news2_backend-1.1.1 app/controllers/ecm/news/backend/items_controller.rb