allow skipping the validations on creation if its an api call AND skip_validations is specified

this allows wordpress plugin to post very very short titles or titles that would otherwise be disallowed
This commit is contained in:
Sam
2013-07-02 12:23:19 +10:00
parent 68d98ec94e
commit f6b850e7a4
5 changed files with 31 additions and 15 deletions
+1 -2
View File
@@ -35,8 +35,6 @@ class Topic < ActiveRecord::Base
rate_limit :limit_topics_per_day
rate_limit :limit_private_messages_per_day
before_validation :sanitize_title
validates :title, :presence => true,
:topic_title_length => true,
:quality_title => { :unless => :private_message? },
@@ -47,6 +45,7 @@ class Topic < ActiveRecord::Base
:collection => Proc.new{ Topic.listable_topics } }
before_validation do
self.sanitize_title
self.title = TextCleaner.clean_title(TextSentinel.title_sentinel(title).text) if errors[:title].empty?
end