class Comment < ActiveRecord::Base @@captchas = { "Eine Ampel hat die Farben GrĂ¼n, Gelb und %FIELD%." => "Rot", "Bananen haben die Farbe %FIELD%." => "Gelb" } hobo_model belongs_to :iteration validates_exclusion_of :comment, :in => ["Dein Kommentar"], :message => "Ist das nicht etwas einfallslos? \"Kommentar\"?" validates_exclusion_of :author, :in => ["Dein Name"], :message => "Ist das nicht etwas einfallslos? \"Dein Name\"?" validate :captcha_coherence attr_accessor :captcha, :captcha_question set_field_type :captcha => String set_field_type :captcha_question => String set_search_columns :comment def captcha_coherence if self.captcha.downcase != @@captchas[self.captcha_question].downcase errors.add :captcha, "captcha unvalid" end end def self.captcha @@captchas.sort_by{ rand }.first end # --- Hobo Permissions --- # def display_name "#{comment} (#{author})" end def creatable_by?(creator) true end def updatable_by?(updater, new) false end def deletable_by?(deleter) false end def viewable_by?(viewer, field) true end end