From c54019052854db2c0d2b7ae24e85959ad1c3e708 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Feb 2011 11:01:02 +0000 Subject: next_id fixed --- application.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/application.rb b/application.rb index 1b84309..de11313 100644 --- a/application.rb +++ b/application.rb @@ -2,9 +2,13 @@ require 'rubygems' gem "opentox-ruby", "~> 0" require 'opentox-ruby' +set :lock, true + helpers do def next_id - Dir["./public/*yaml"].collect{|f| File.basename(f.sub(/.yaml/,'')).to_i}.sort.last + 1 + id = Dir["./public/*yaml"].collect{|f| File.basename(f.sub(/.yaml/,'')).to_i}.sort.last + id = 0 if id.nil? + id + 1 end def uri(id) @@ -83,9 +87,7 @@ end before do @accept = request.env['HTTP_ACCEPT'] @accept = 'application/rdf+xml' if @accept == '*/*' or @accept == '' or @accept.nil? - LOGGER.debug "PARAMS" @id = request.path_info.match(/^\/\d+/) - LOGGER.debug @id unless @id.nil? @id = @id.to_s.sub(/\//,'').to_i -- cgit v1.2.3