Sha256: 9b4da7610b0942e26ff0458467d71476a40baabf492b1d072c9d4cf9ea0ce5ad

Contents?: true

Size: 1.37 KB

Versions: 7

Compression:

Stored size: 1.37 KB

Contents

module Saucy
  module ProjectsController
    extend ActiveSupport::Concern

    included do
      before_filter :authorize_admin
      layout Saucy::Layouts.to_proc
    end

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

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

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

      def update
        @project = ::Project.find(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 destroy
        @project = ::Project.find(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

      private

      def current_account
        if params[:id]
          ::Project.find(params[:id]).account
        else
          super
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
saucy-0.1.9 lib/saucy/projects_controller.rb
saucy-0.1.8 lib/saucy/projects_controller.rb
saucy-0.1.7 lib/saucy/projects_controller.rb
saucy-0.1.6 lib/saucy/projects_controller.rb
saucy-0.1.5 lib/saucy/projects_controller.rb
saucy-0.1.4 lib/saucy/projects_controller.rb
saucy-0.1.3 lib/saucy/projects_controller.rb