Sha256: 7a32acb387673d828be7c611e8aa135fefbf87737b7638ec1101a629d3b2a81e

Contents?: true

Size: 1023 Bytes

Versions: 5

Compression:

Stored size: 1023 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.root_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

5 entries across 5 versions & 1 rubygems

Version Path
backlog-0.10.5 app/controllers/estimates_controller.rb
backlog-0.10.7 app/controllers/estimates_controller.rb
backlog-0.10.6 app/controllers/estimates_controller.rb
backlog-0.10.8 app/controllers/estimates_controller.rb
backlog-0.11.0 app/controllers/estimates_controller.rb