Sha256: a73f45ec56bbb9b6adb3b355c960b1e72284c2ac71be905fc9526427f401e2e4

Contents?: true

Size: 1.52 KB

Versions: 5

Compression:

Stored size: 1.52 KB

Contents

module Portfolio
  module Admin
    class SitesController < ApplicationController
      before_action :set_site, only: [:show, :edit, :update, :destroy]
      before_action Portfolio.auth_action

      def index
        @sites = Site.all
      end

      def new
        @site = Site.new
      end

      def edit
      end

      def create
        @site = Site.new(item_params)

        respond_to do |format|
          if @site.save
            format.html { redirect_to show_portfolio_path(@site.key), notice: 'Site was successfully created.' }
          else
            format.html { render :new }
          end
        end
      end

      def update
        respond_to do |format|
          if @site.update(item_params)
            format.html { redirect_to show_portfolio_path(@site.key), notice: 'Site was successfully updated.' }
          else
            format.html { render :edit }
          end
        end
      end

      def destroy
        @site.destroy
        respond_to do |format|
          format.html { redirect_to [:admin, :sites], notice: 'Site was successfully destroyed.' }
        end
      end

      private
        # Use callbacks to share common setup or constraints between actions.
        def set_site
          @site = Site.find(params[:id])
        end

        # Never trust parameters from the scary internet, only allow the white list through.
        def item_params
          params.require(:site).permit(:key, :job_title, :summary, :avatar, :default, :email, :person_name, :greetings)
        end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails-portfolio-0.0.5 app/controllers/portfolio/admin/sites_controller.rb
rails-portfolio-0.0.4 app/controllers/portfolio/admin/sites_controller.rb
rails-portfolio-0.0.3 app/controllers/portfolio/admin/sites_controller.rb
rails-portfolio-0.0.2 app/controllers/portfolio/admin/sites_controller.rb
rails-portfolio-0.0.1 app/controllers/portfolio/admin/sites_controller.rb