Sha256: 3d0f31464646621291e6ff4e723f21ef4de40c05a63c69f48633dcd543a008a2

Contents?: true

Size: 1.24 KB

Versions: 5

Compression:

Stored size: 1.24 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_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 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

5 entries across 5 versions & 1 rubygems

Version Path
saucy-0.1.16 lib/saucy/projects_controller.rb
saucy-0.1.15 lib/saucy/projects_controller.rb
saucy-0.1.14 lib/saucy/projects_controller.rb
saucy-0.1.13 lib/saucy/projects_controller.rb
saucy-0.1.12 lib/saucy/projects_controller.rb