Module: TagsHelper

Defined in:
app/helpers/tags_helper.rb

Overview

Copyright © 2008-2013 Michael Dvorkin and contributors.

Fat Free CRM is freely distributable under the terms of MIT license. See MIT-LICENSE file or www.opensource.org/licenses/mit-license.php


Instance Method Summary collapse

Instance Method Details

#tags_for_dashboard(model) ⇒ Object



24
25
26
27
28
29
30
# File 'app/helpers/tags_helper.rb', line 24

def tags_for_dashboard(model)
  (:ul) do
    model.tags.each do |tag|
      concat((:li, tag.name))
    end
  end
end

#tags_for_index(model) ⇒ Object

Generate tag links for use on asset index pages.




11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/helpers/tags_helper.rb', line 11

def tags_for_index(model)
  model.tags.inject("".html_safe) do |out, tag|
    query = controller.send(:current_query) || ""
    hashtag = "##{tag}"
    if query.empty?
      query = hashtag
    elsif !query.include?(hashtag)
      query += " #{hashtag}"
    end
    out << link_to_function(tag, "crm.search_tagged('#{escape_javascript(query)}', '#{model.class.to_s.tableize}')", title: tag)
  end
end