dmail.rb: validate only on creation.
to/from/title/body don't need to be revalidated after creation since they never change.
This commit is contained in:
@@ -1,12 +1,15 @@
|
|||||||
require 'digest/sha1'
|
require 'digest/sha1'
|
||||||
|
|
||||||
class Dmail < ActiveRecord::Base
|
class Dmail < ActiveRecord::Base
|
||||||
validates_presence_of :to_id
|
with_options on: :create do
|
||||||
validates_presence_of :from_id
|
before_validation :initialize_from_id
|
||||||
validates_format_of :title, :with => /\S/
|
validates_presence_of :to_id
|
||||||
validates_format_of :body, :with => /\S/
|
validates_presence_of :from_id
|
||||||
validate :validate_sender_is_not_banned
|
validates_format_of :title, :with => /\S/
|
||||||
before_validation :initialize_from_id, :on => :create
|
validates_format_of :body, :with => /\S/
|
||||||
|
validate :validate_sender_is_not_banned
|
||||||
|
end
|
||||||
|
|
||||||
belongs_to :owner, :class_name => "User"
|
belongs_to :owner, :class_name => "User"
|
||||||
belongs_to :to, :class_name => "User"
|
belongs_to :to, :class_name => "User"
|
||||||
belongs_to :from, :class_name => "User"
|
belongs_to :from, :class_name => "User"
|
||||||
|
|||||||
Reference in New Issue
Block a user