app/models/refinery/inquiries/inquiry.rb in refinerycms-inquiries-2.0.3 vs app/models/refinery/inquiries/inquiry.rb in refinerycms-inquiries-2.1.0
- old
+ new
@@ -1,5 +1,8 @@
+require 'refinery/core/base_model'
+require 'filters_spam'
+
module Refinery
module Inquiries
class Inquiry < Refinery::Core::BaseModel
filters_spam :message_field => :message,
@@ -7,21 +10,19 @@
:author_field => :name,
:other_fields => [:phone],
:extra_spam_words => %w()
validates :name, :presence => true
+ validates :email, :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i }
validates :message, :presence => true
- validates :email, :format=> { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
- acts_as_indexed :fields => [:name, :email, :message, :phone]
-
default_scope :order => 'created_at DESC'
attr_accessible :name, :phone, :message, :email
def self.latest(number = 7, include_spam = false)
include_spam ? limit(number) : ham.limit(number)
end
end
end
-end
\ No newline at end of file
+end