- File.open(filename, "w") { |f| f.write(params[:trace][:gpx_file].read) }
- params[:trace][:name] = params[:trace][:gpx_file].original_filename.gsub(/[^a-zA-Z0-9.]/, '_') # This makes sure filenames are sane
- params[:trace].delete('gpx_file') # remove the field from the hash, because there's no such field in the DB
- @trace = Trace.new(params[:trace])
- @trace.inserted = false
- @trace.user = @user
- @trace.timestamp = Time.now
-
- if @trace.save
- saved_filename = "/home/osm/gpx/#{@trace.id}.gpx"
- File.rename(filename, saved_filename)
+ do_create(name, params[:trace][:tagstring], params[:trace][:description], params[:trace][:public]) do |f|
+ f.write(params[:trace][:gpx_file].read)
+ end