]> git.openstreetmap.org Git - rails.git/blob - app/models/redaction.rb
Improve character validator error messages
[rails.git] / app / models / redaction.rb
1 # == Schema Information
2 #
3 # Table name: redactions
4 #
5 #  id                 :integer          not null, primary key
6 #  title              :string
7 #  description        :text
8 #  created_at         :datetime
9 #  updated_at         :datetime
10 #  user_id            :integer          not null
11 #  description_format :enum             default("markdown"), not null
12 #
13 # Foreign Keys
14 #
15 #  redactions_user_id_fkey  (user_id => users.id)
16 #
17
18 ##
19 # Redaction represents a record associated with a particular
20 # action on the database to hide revisions from the history
21 # which are not appropriate to redistribute any more.
22 #
23 # The circumstances of the redaction can be recorded in the
24 # record's title and description fields, which can be
25 # displayed linked from the redacted records.
26 #
27 class Redaction < ActiveRecord::Base
28   belongs_to :user
29
30   has_many :old_nodes
31   has_many :old_ways
32   has_many :old_relations
33
34   validates :title, :presence => true, :characters => true
35   validates :description, :presence => true, :characters => true
36   validates :description_format, :inclusion => { :in => %w[text html markdown] }
37
38   # this method overrides the AR default to provide the rich
39   # text object for the description field.
40   def description
41     RichText.new(self[:description_format], self[:description])
42   end
43 end