]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/trace.rb
Fix some rubocop rails style issues
[rails.git] / app / models / trace.rb
index 1a935293a9acc7cf0a8bea0ebf6a9402021b221a..994bafcf13cc9738124ed05f572fc8990c8324bc 100644 (file)
@@ -10,13 +10,11 @@ class Trace < ActiveRecord::Base
   scope :visible_to_all, -> { where(:visibility => %w(public identifiable)) }
   scope :tagged, ->(t) { joins(:tags).where(:gpx_file_tags => { :tag => t }) }
 
-  validates_presence_of :user_id, :name, :timestamp
-  validates_presence_of :description, :on => :create
-  validates_length_of :name, :maximum => 255
-  validates_length_of :description, :maximum => 255
-  #  validates_numericality_of :latitude, :longitude
-  validates_inclusion_of :inserted, :in => [true, false]
-  validates_inclusion_of :visibility, :in => %w(private public trackable identifiable)
+  validates :user, :presence => true, :associated => true
+  validates :name, :presence => true, :length => 1..255
+  validates :description, :presence => { :on => :create }, :length => 1..255
+  validates :timestamp, :presence => true
+  validates :visibility, :inclusion => %w(private public trackable identifiable)
 
   def destroy
     super
@@ -219,7 +217,7 @@ class Trace < ActiveRecord::Base
   end
 
   def xml_file
-    # TODO *nix specific, could do to work on windows... would be functionally inferior though - check for '.gz'
+    # TODO: *nix specific, could do to work on windows... would be functionally inferior though - check for '.gz'
     filetype = `/usr/bin/file -bz #{trace_name}`.chomp
     gzipped = filetype =~ /gzip compressed/
     bzipped = filetype =~ /bzip2 compressed/