Sha256: 2cf3abd47e4749cdcbce7c8e455f72cac9539864d3a827d6a9cf67ce6cc4d760

Contents?: true

Size: 1.44 KB

Versions: 15

Compression:

Stored size: 1.44 KB

Contents

module Saucy
  module ProjectsController
    extend ActiveSupport::Concern

    included do
      before_filter :authorize_admin, :except => [:show]
      before_filter :ensure_active_account, :only => [:show, :destroy, :index]
      layout Saucy::Layouts.to_proc
    end

    module InstanceMethods
      def new
        @project = current_account.projects.build_with_default_permissions
      end

      def create
        @project = current_account.projects.build(params[:project])
        if @project.save
          flash[:notice] = "Project successfully created"
          redirect_to project_url(@project)
        else
          render :action => :new
        end
      end

      def edit
        @project = ::Project.find_by_keyword!(params[:id])
      end

      def update
        @project = ::Project.find_by_keyword!(params[:id])
        if @project.update_attributes params[:project]
          flash[:success] = 'Project was updated.'
          redirect_to account_projects_url(current_account)
        else
          render :action => :edit
        end
      end

      def show
        @project = ::Project.find_by_keyword!(params[:id])
      end

      def destroy
        @project = ::Project.find_by_keyword!(params[:id])
        @project.destroy
        flash[:success] = "Project has been deleted"
        redirect_to account_projects_url(@project.account)
      end

      def index
        @projects = current_account.projects
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
saucy-0.2.28.1 lib/saucy/projects_controller.rb
saucy-0.2.40 lib/saucy/projects_controller.rb
saucy-0.2.39 lib/saucy/projects_controller.rb
saucy-0.2.38 lib/saucy/projects_controller.rb
saucy-0.2.36 lib/saucy/projects_controller.rb
saucy-0.2.35 lib/saucy/projects_controller.rb
saucy-0.2.34 lib/saucy/projects_controller.rb
saucy-0.2.33 lib/saucy/projects_controller.rb
saucy-0.2.32 lib/saucy/projects_controller.rb
saucy-0.2.31 lib/saucy/projects_controller.rb
saucy-0.2.30 lib/saucy/projects_controller.rb
saucy-0.2.29 lib/saucy/projects_controller.rb
saucy-0.2.28 lib/saucy/projects_controller.rb
saucy-0.2.27 lib/saucy/projects_controller.rb
saucy-0.2.26 lib/saucy/projects_controller.rb