Class: Post
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Post
- Defined in:
- app/models/post.rb
Constant Summary collapse
- @@per_page =
Spree::Config[:cms_posts_per_page]
Class Method Summary collapse
-
.find_all_tagged_with(tag_or_tags, conditions = []) ⇒ Object
should be part of is_taggable pulled from github.com/gnugeek/is_taggable/commit/10b590865f0effeed20f00e3581a7aed8a6bd3b4.
Instance Method Summary collapse
- #format_markup ⇒ Object
- #month ⇒ Object
-
#published ⇒ Object
def link ensure_slash_prefix permalink end.
- #to_param ⇒ Object
Class Method Details
.find_all_tagged_with(tag_or_tags, conditions = []) ⇒ Object
should be part of is_taggable pulled from github.com/gnugeek/is_taggable/commit/10b590865f0effeed20f00e3581a7aed8a6bd3b4
26 27 28 29 30 31 32 33 34 |
# File 'app/models/post.rb', line 26 def self.find_all_tagged_with(, conditions=[]) return [] if .nil? || .empty? case when Array, IsTaggable::TagList includes('tags', 'taggings').where(conditions).select { |record| .all? { |tag| record..map(&:name).include?(tag) } } || [] else includes('tags', 'taggings').where(conditions).select { |record| record..map(&:name).include?() } || [] end end |
Instance Method Details
#format_markup ⇒ Object
41 42 43 44 45 |
# File 'app/models/post.rb', line 41 def format_markup if not self.body_raw.nil? self.body = RedCloth.new(self.body_raw,[:sanitize_html, :filter_html]).to_html end end |
#month ⇒ Object
64 65 66 |
# File 'app/models/post.rb', line 64 def month published_at.strftime('%B %Y') end |
#published ⇒ Object
def link
ensure_slash_prefix permalink
end
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/models/post.rb', line 51 def published #self.published_at ||= Time.now unless self.is_active == 0 if self.is_active == 0 if !self.published_at.blank? self.published_at = nil end else if self.published_at.blank? self.published_at = Time.now end end end |
#to_param ⇒ Object
36 37 38 39 |
# File 'app/models/post.rb', line 36 def to_param return permalink unless permalink.blank? title.to_url end |