Sha256: 28c0cf8bafa12b95619b0b3cb1a469f06af53802f06f05cdf87581861bf1b882

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

module Adminpanel
  class SectionsController < Adminpanel::ApplicationController
    def index
      @sections = Section.all
    end

    # def new
    #   @section = Section.new
    #   authorize! :create, @section
    # end

    def edit
      @section = Section.find(params[:id])
      # respond_to do |format|
        # format.html
        # format.json {render :json => {:section => @section }}
      # end
    end

    def update
      @section = Section.find(params[:id])

      if @section.update(section_params)
        redirect_to section_path(@section), notice: 'La seccion se ha actualizado'
      else
        render 'edit'
      end
    end

    def show
      @section = Section.find(params[:id])
    end

    private
    def section_params
      params.require(:section).permit(
        :has_description,
        :description,
        :key,
        :page,
        :name,
        :max_files,
        :has_image,
        {
          sectionfiles_attributes: [
            :id,
            :file,
            :_destroy
          ]
        }
      )
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
adminpanel-2.4.0 app/controllers/adminpanel/sections_controller.rb
adminpanel-2.3.1 app/controllers/adminpanel/sections_controller.rb
adminpanel-2.3.0 app/controllers/adminpanel/sections_controller.rb