Sha256: 81a1d23012e7ac5f8bf66735972132c7c9f72357a50b5f0437c4c9423af04af4

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 KB

Contents

module Mokio
  module Concerns
    module Controllers
      #
      # Concern for MovGalleriesController
      #
      module MovGalleries
        extend ActiveSupport::Concern

        included do

          before_action :init_obj, :set_author, :only =>[:create]
          before_action :set_editor, :only => [:create, :update]

        end

        def init_obj
          @mov_gallery = Mokio::MovGallery.new(mov_gallery_params)
        end

        def set_author
          @mov_gallery.created_by = current_user.id
        end

        def set_editor
          obj.updated_by = current_user.id
          set_author if obj.created_by.blank? # for backward compatibility
        end


        #
        # Overriten create from CommonController#create (Mokio::Concerns::Controllers::Common)
        #
        def create
          respond_to do |format|
            if @mov_gallery.save
              if !params[:save_and_new].blank?
                format.html { redirect_to new_mov_gallery_path, notice: t("mov_galleries.created_and_new", title: @mov_gallery.title) }
              else
                format.html { redirect_to edit_content_path(@mov_gallery), notice: t("mov_galleries.created", title: @mov_gallery.title) }
              end
            else
              format.html { render "new", notice: t("mov_galleries.not_created", title: @mov_gallery) }
            end
          end
        end

        def set_breadcrumbs_prefix
          @breadcrumbs_prefix = "content_management"
          @breadcrumbs_prefix_link = "contents"
        end

        private
          #
          # Never trust parameters from the scary internet, only allow the white list through.
          #
          def mov_gallery_params #:doc:
            params.require(:mov_gallery).permit(mokio_gems_parameters,:title, :subtitle, :type, :active, :home_page ,:intro, :content, :display_from, :display_to, :lang_id, :main_pic, :tag_list, :menu_ids => [], :data_file => [])
          end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mokio-2.0.8 lib/mokio/concerns/controllers/mov_galleries.rb