Class: Sections::Model::Section
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- Sections::Model::Section
- Includes:
- Zen::Model::Helper
- Defined in:
- lib/zen/package/sections/lib/sections/model/section.rb
Overview
Model that represents a single section.
Constant Summary
Constant Summary
Constants included from Zen::Model::Helper
Zen::Model::Helper::NoRegexpSupport
Class Method Summary (collapse)
-
+ (Mixed) search(query)
Searches for a number of sections of which the title or description matches the search query.
Instance Method Summary (collapse)
-
- (Object) validate
Specifies all validation rules for each section.
Methods included from Zen::Model::Helper
Methods inherited from Sequel::Model
Class Method Details
+ (Mixed) search(query)
Searches for a number of sections of which the title or description matches the search query.
35 36 37 38 39 |
# File 'lib/zen/package/sections/lib/sections/model/section.rb', line 35 def self.search(query) return filter( search_column(:name, query) | search_column(:description, query) ) end |
Instance Method Details
- (Object) validate
Specifies all validation rules for each section.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/zen/package/sections/lib/sections/model/section.rb', line 46 def validate validates_presence([ :name, :comment_allow, :comment_require_account, :comment_moderate, :comment_format ]) validates_max_length(255, [:name, :slug]) validates_type( TrueClass, [:comment_allow, :comment_require_account, :comment_moderate] ) validates_unique(:slug) end |