Class: WsItem
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- WsItem
- Defined in:
- app/models/ws_item.rb
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
- #generate_permalink ⇒ Object
- #link ⇒ Object
- #month ⇒ Object
- #published ⇒ Object
- #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
23 24 25 26 27 28 29 30 31 |
# File 'app/models/ws_item.rb', line 23 def self.find_all_tagged_with(, conditions=[]) return [] if .nil? || .empty? case when Array, IsTaggable::TagList all(:include => ['tags', 'taggings'], :conditions => conditions ).select { |record| .all? { |tag| record..map(&:name).include?(tag) } } || [] else all(:include => ['tags', 'taggings'], :conditions => conditions).select { |record| record..map(&:name).include?() } || [] end end |
Instance Method Details
#format_markup ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/ws_item.rb', line 33 def format_markup self.body = RedCloth.new(self.body_raw,[:sanitize_html, :filter_html]).to_html #~ if self.excerpt.blank? #~ self.excerpt = self.body.gsub(/\<[^\>]+\>/, '')[0...50] + "..." #~ else #~ self.excerpt = self.excerpt.gsub(/\<[^\>]+\>/, '') #~ end end |
#generate_permalink ⇒ Object
44 45 46 47 |
# File 'app/models/ws_item.rb', line 44 def generate_permalink self.permalink = self.title.dup if self.permalink.blank? self.permalink.linkify! end |
#link ⇒ Object
49 50 51 |
# File 'app/models/ws_item.rb', line 49 def link ensure_slash_prefix permalink end |
#month ⇒ Object
66 67 68 |
# File 'app/models/ws_item.rb', line 66 def month published_at.strftime('%B %Y') end |
#published ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/models/ws_item.rb', line 53 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
70 71 72 |
# File 'app/models/ws_item.rb', line 70 def to_param "#{id}-#{permalink}" end |