summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2010-08-19 11:23:18 +0200
committermguetlein <martin.guetlein@gmail.com>2010-08-19 11:23:18 +0200
commit4911d9a1fc677dc70287b11ba1f26b425ddc3b09 (patch)
treebc6e5e40ac9210436f32b3b1bf626ee7111f4182
parent47bdf2c5e3a01b2fd18cbd4ec19536d6fd6fb23a (diff)
take params into account when create new task
-rw-r--r--application.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/application.rb b/application.rb
index 57e9ecb..b177e3c 100644
--- a/application.rb
+++ b/application.rb
@@ -65,14 +65,15 @@ get '/:id/:property/?' do
end
post '/?' do
- LOGGER.debug "Creating new task ..."
- task = Task.new
- task.save # needed to create id
- task.uri = url_for("/#{task.id}", :full)
- task.due_to_time = DateTime.parse((Time.parse(task.created_at.to_s) + params[:max_duration].to_f).to_s) if params[:max_duration]
- raise "could not save" unless task.save
- response['Content-Type'] = 'text/uri-list'
- task.uri + "\n"
+ LOGGER.debug "Creating new task with params "+params.inspect
+ max_duration = params.delete(:max_duration.to_s) if params.has_key?(:max_duration.to_s)
+ task = Task.new(params)
+ task.save # needed to create id
+ task.uri = url_for("/#{task.id}", :full)
+ task.due_to_time = DateTime.parse((Time.parse(task.created_at.to_s) + max_duration.to_f).to_s) if max_duration
+ raise "could not save" unless task.save
+ response['Content-Type'] = 'text/uri-list'
+ task.uri + "\n"
end
put '/:id/:hasStatus/?' do