Sha256: 642bdb7c309ed1f69579bd0811dd55fc4a835b68e152e065c203f8406c59f506

Contents?: true

Size: 1.17 KB

Versions: 8

Compression:

Stored size: 1.17 KB

Contents

class ProjectsController < ApplicationController
  include Applicat::Mvc::Controller::Resource
  
  load_and_authorize_resource
  
  respond_to :html, :js, :json
  
  def index
    @parent = find_parent Project::PARENT_TYPES
    @projects = @parent ? @parent.projects.order(:name) : Project.order(:name)
  end
  
  def show
    @project = Project.includes(:areas, :comments).find(params[:id])
    @comments = @project.comments
  end
  
  def new
    @project = Project.new
  end
  
  def create
    @project = Project.new(params[:project])
    @project.user_id = current_user.id
    
    if @project.save
      redirect_to @project, notice: t('general.form.successfully_created')
    else
      render :new
    end
  end
  
  def edit
    @project = Project.find(params[:id])
  end
  
  def update
    @project = Project.find(params[:id])
    
    if @project.update_attributes(params[:project])
      redirect_to @project, notice: t('general.form.successfully_updated')
    else
      render :edit
    end
  end

  def destroy
    @project = Project.find(params[:id])
    @project.destroy
    redirect_to projects_url, notice: t('general.form.destroyed')
  end
  
  def resource
    @project
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
voluntary-0.1.0 app/controllers/projects_controller.rb
voluntary-0.1.0.rc4 app/controllers/projects_controller.rb
voluntary-0.1.0.rc3 app/controllers/projects_controller.rb
voluntary-0.1.0.rc2 app/controllers/projects_controller.rb
voluntary-0.1.0.rc1 app/controllers/projects_controller.rb
voluntary-0.0.3 app/controllers/projects_controller.rb
voluntary-0.0.2 app/controllers/projects_controller.rb
voluntary-0.0.1 app/controllers/projects_controller.rb