change some before_create's to before_validation, :on => :create
random tokens need to be filled in before validation, otherwise the validation is just checking a blank value
This commit is contained in:
parent
4f8c302edb
commit
ccb8094da1
|
@ -13,8 +13,11 @@ class Comment < ActiveRecord::Base
|
||||||
attr_accessor :parent_comment_short_id, :current_vote, :previewing,
|
attr_accessor :parent_comment_short_id, :current_vote, :previewing,
|
||||||
:indent_level, :highlighted
|
:indent_level, :highlighted
|
||||||
|
|
||||||
before_create :assign_short_id_and_upvote, :assign_initial_confidence,
|
before_validation :on => :create do
|
||||||
:assign_thread_id
|
self.assign_short_id_and_upvote
|
||||||
|
self.assign_initial_confidence
|
||||||
|
self.assign_thread_id
|
||||||
|
end
|
||||||
after_create :assign_votes, :mark_submitter, :deliver_reply_notifications,
|
after_create :assign_votes, :mark_submitter, :deliver_reply_notifications,
|
||||||
:deliver_mention_notifications, :log_to_countinual
|
:deliver_mention_notifications, :log_to_countinual
|
||||||
after_destroy :unassign_votes
|
after_destroy :unassign_votes
|
||||||
|
|
|
@ -9,7 +9,8 @@ class Invitation < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
before_create :create_code
|
before_validation :create_code,
|
||||||
|
:on => :create
|
||||||
|
|
||||||
def create_code
|
def create_code
|
||||||
(1...10).each do |tries|
|
(1...10).each do |tries|
|
||||||
|
|
|
@ -16,7 +16,8 @@ class Message < ActiveRecord::Base
|
||||||
validates_length_of :subject, :in => 1..150
|
validates_length_of :subject, :in => 1..150
|
||||||
validates_length_of :body, :maximum => (64 * 1024)
|
validates_length_of :body, :maximum => (64 * 1024)
|
||||||
|
|
||||||
before_create :assign_short_id
|
before_validation :assign_short_id,
|
||||||
|
:on => :create
|
||||||
after_create :deliver_reply_notifications
|
after_create :deliver_reply_notifications
|
||||||
after_save :update_unread_counts
|
after_save :update_unread_counts
|
||||||
after_save :check_for_both_deleted
|
after_save :check_for_both_deleted
|
||||||
|
|
|
@ -18,7 +18,7 @@ class ShortId
|
||||||
CandidateId.new(klass)
|
CandidateId.new(klass)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
class CandidateId
|
class CandidateId
|
||||||
attr_accessor :klass, :id
|
attr_accessor :klass, :id
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,8 @@ class Story < ActiveRecord::Base
|
||||||
|
|
||||||
attr_accessible :title, :description, :tags_a, :moderation_reason
|
attr_accessible :title, :description, :tags_a, :moderation_reason
|
||||||
|
|
||||||
before_create :assign_short_id
|
before_validation :assign_short_id,
|
||||||
|
:on => :create
|
||||||
before_save :log_moderation
|
before_save :log_moderation
|
||||||
after_create :mark_submitter
|
after_create :mark_submitter
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,10 @@ class User < ActiveRecord::Base
|
||||||
:pushover_mentions, :mailing_list_enabled
|
:pushover_mentions, :mailing_list_enabled
|
||||||
|
|
||||||
before_save :check_session_token
|
before_save :check_session_token
|
||||||
before_create :create_rss_token, :create_mailing_list_token
|
before_validation :on => :create do
|
||||||
|
self.create_rss_token
|
||||||
|
self.create_mailing_list_token
|
||||||
|
end
|
||||||
after_create :create_default_tag_filters
|
after_create :create_default_tag_filters
|
||||||
|
|
||||||
BANNED_USERNAMES = [ "admin", "administrator", "hostmaster", "mailer-daemon",
|
BANNED_USERNAMES = [ "admin", "administrator", "hostmaster", "mailer-daemon",
|
||||||
|
|
Loading…
Reference in a new issue