Sha256: 6d14ddc8b5836bbb6a940b8a326eb62ba7f8522d87e313b1dbeb92cee3f06eba
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
class WorkAccountsController < ApplicationController def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def list @work_accounts = WorkAccount.paginate :page => params[:page] end def show @work_account = WorkAccount.find(params[:id]) works = @work_account.works.select{|w|w.user_id == current_user.id} @backlog_totals = works.to_summarized_hash {|work| [work.task && work.task.backlog, work.hours]} @task_totals = works.to_summarized_hash {|work| [work.task, work.hours]} @task_totals_per_backlog = @task_totals.to_a.to_grouped_hash {|task, hours| [task && task.backlog, [task, hours]]} @total_hours = works.inject(BigDecimal('0')) {|total, work| total += work.hours} end def new @work_account = WorkAccount.new end def create @work_account = WorkAccount.new(params[:work_account]) if @work_account.save flash[:notice] = 'WorkAccount was successfully created.' redirect_to :action => 'list' else render :action => 'new' end end def edit @work_account = WorkAccount.find(params[:id]) end def update @work_account = WorkAccount.find(params[:id]) if @work_account.update_attributes(params[:work_account]) flash[:notice] = 'WorkAccount was successfully updated.' back_or_redirect_to :action => 'show', :id => @work_account else render :action => 'edit' end end def destroy WorkAccount.find(params[:id]).destroy redirect_to :action => 'list' end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
backlog-0.17.6 | app/controllers/work_accounts_controller.rb |
backlog-0.18.0 | app/controllers/work_accounts_controller.rb |