Sha256: 9fd1ef8c99db6f244e65aa6291f805077ba22450f2d1b7fd27694501e041cc61

Contents?: true

Size: 1013 Bytes

Versions: 9

Compression:

Stored size: 1013 Bytes

Contents

class EstimatesController < ApplicationController
  verify :method => :post, :redirect_to => ''
  
  def create
    if params[:id]
      @task = Task.find(params[:id])
      if params[:estimate] && params[:estimate][:todo]
        begin
          Float(params[:estimate][:todo])
          @task.estimate(params[:estimate][:todo])
          flash[:notice] = 'Estimate updated'
          rescue ArgumentError => e
          @task.errors.add :estimate, "was not numeric"
          render :file => "public/500.html", :layout => true, :status => 500
          return
        end
        redirect_to :controller => 'periods', :action => :show, :id => @task.period, :task_id => @task.id
      else
        @task.errors.add :task, 'Estimate is missing.'
        render :file => "public/500.html", :layout => true, :status => 500
      end
    else
      @estimate = Estimate.new
      @estimate.errors.add :task, 'Id is missing.'
      render :file => "public/500.html", :layout => true, :status => 500
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
backlog-0.10.0 app/controllers/estimates_controller.rb
backlog-0.10.1 app/controllers/estimates_controller.rb
backlog-0.10.2 app/controllers/estimates_controller.rb
backlog-0.10.3 app/controllers/estimates_controller.rb
backlog-0.10.4 app/controllers/estimates_controller.rb
backlog-0.8.0 app/controllers/estimates_controller.rb
backlog-0.9.0 app/controllers/estimates_controller.rb
backlog-0.8.1 app/controllers/estimates_controller.rb
backlog-0.9.1 app/controllers/estimates_controller.rb