Module: LoyalCore::ActsAsHasPermalink::ClassMethods
- Defined in:
- lib/loyal_core/acts/has_permalink.rb
Defined Under Namespace
Modules: WithSpaceMethods
Instance Method Summary collapse
Instance Method Details
#loyal_core_acts_as_has_permalink(*args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/loyal_core/acts/has_permalink.rb', line 13 def loyal_core_acts_as_has_permalink *args = args. field_name = args.first || :permalink include WithSpaceMethods if [:with_space] validates_format_of field_name, :with => PERMALINK_REGEXP, :unless => :space_root?, :multiline => true validates_presence_of field_name, :unless => :space_root? # space 格式要求正确 validates_format_of :space, :with => PERMALINK_REGEXP, :multiline => true if [:paranoid] self.validates_uniqueness_of_without_deleted field_name, :scope => [:space] else validates_uniqueness_of field_name, :uniqueness => {:scope => [:space]} end else validates_format_of field_name, :with => PERMALINK_REGEXP, :multiline => true validates_presence_of field_name if [:paranoid] self.validates_uniqueness_of_without_deleted field_name else validates_uniqueness_of field_name end end end |