]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/tracetag.rb
Add inverse_of to relationships that can't detect it automatically
[rails.git] / app / models / tracetag.rb
index 1a4fbd39889195a4653fcc1ed9fec5be3d8e4126..70296cd54f15115c95a4dcac43d01f234539f554 100644 (file)
@@ -2,9 +2,9 @@
 #
 # Table name: gpx_file_tags
 #
-#  gpx_id :integer          default(0), not null
+#  gpx_id :bigint(8)        default(0), not null
 #  tag    :string           not null
-#  id     :integer          not null, primary key
+#  id     :bigint(8)        not null, primary key
 #
 # Indexes
 #
 #  gpx_file_tags_gpx_id_fkey  (gpx_id => gpx_files.id)
 #
 
-class Tracetag < ActiveRecord::Base
+class Tracetag < ApplicationRecord
   self.table_name = "gpx_file_tags"
 
-  belongs_to :trace, :foreign_key => "gpx_id"
+  belongs_to :trace, :foreign_key => "gpx_id", :inverse_of => :tags
 
   validates :trace, :associated => true
-  validates :tag, :length => 1..255, :format => %r{\A[^/;.,?]*\z}
+  validates :tag, :length => 1..255, :characters => { :url_safe => true }
 end