Sha256: c3f691431f4a969b8b6080fff66aa2f80f89211ba72c27088eb611c878f6b520

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

module Adminpanel
  class SectionsController < Adminpanel::ApplicationController
    load_and_authorize_resource

    def new
      @section = Section.new
    end

    # def create
    #   @section = Section.new(params[:section])

    #   if @section.save
    #     redirect_to section_path(@section), :notice => 'La seccion ha sido creada'
    #   else
    #     render 'new'
    #   end
    # 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_attributes(params[:section])
        redirect_to section_path(@section), :notice => "La seccion se ha actualizado"
      else
        render 'edit'
      end
    end

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

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

    #   redirect_to sections_path
    # end

    def index
      @sections = Section.all
    end

    private
    def section_params
      params.require(:section).permit(
      :description,
      :has_image,
      :key,
      :page,
      :name,
      :has_description,
      :images_attributes => [:id, :file]
      )

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adminpanel-2.0.0 app/controllers/adminpanel/sections_controller.rb