Class: Helpdesk::Faq
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Helpdesk::Faq
- Defined in:
- app/models/helpdesk/faq.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.collection ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'app/models/helpdesk/faq.rb', line 33 def self.collection arr = [] roots.each do |faq| arr << faq arr << faq.descendants end return arr.flatten end |
.search(query, page = 1) ⇒ Object
21 22 23 24 25 26 27 |
# File 'app/models/helpdesk/faq.rb', line 21 def self.search(query, page=1) query = "%#{query}%" arel_faqs_t = Arel::Table.new(:helpdesk_faq_translations) name_match = arel_faqs_t[:title].matches(query) postal_match = arel_faqs_t[:text].matches(query) with_translations.active.where(name_match.or(postal_match)).page(page) end |
Instance Method Details
#anchor ⇒ Object
29 30 31 |
# File 'app/models/helpdesk/faq.rb', line 29 def anchor "##{to_param}" end |
#name_with_depth ⇒ Object
13 14 15 |
# File 'app/models/helpdesk/faq.rb', line 13 def name_with_depth "#{" "*depth}\\_ #{title}".html_safe end |
#to_param ⇒ Object
17 18 19 |
# File 'app/models/helpdesk/faq.rb', line 17 def to_param id ? "#{id}-#{title.parameterize}" : nil end |