Module: MyTags::ApplicationHelper
- Defined in:
- app/helpers/my_tags/application_helper.rb
Instance Method Summary collapse
-
#all_tags(opts = {}) ⇒ Object
Show all tags.
-
#tag_list(obj, opts = {}) ⇒ Object
Show all object tags.
- #tag_list_with_link(tag_list) ⇒ Object
- #tags_field_tag(object) ⇒ Object
Instance Method Details
#all_tags(opts = {}) ⇒ Object
Show all tags
17 18 19 20 21 |
# File 'app/helpers/my_tags/application_helper.rb', line 17 def (opts = {}) content_tag :div, class: opts.fetch(:html_class, nil) do tag_list_with_link(Tag.uniq(:name)) end.html_safe end |
#tag_list(obj, opts = {}) ⇒ Object
Show all object tags
10 11 12 13 14 |
# File 'app/helpers/my_tags/application_helper.rb', line 10 def tag_list(obj, opts = {}) content_tag :div, class: opts.fetch(:html_class, nil) do tag_list_with_link(obj.) end.html_safe end |
#tag_list_with_link(tag_list) ⇒ Object
23 24 25 26 27 28 29 |
# File 'app/helpers/my_tags/application_helper.rb', line 23 def tag_list_with_link(tag_list) tag_list.map do |tag| content_tag :a, href: tag_path(tag.name) do tag.name.capitalize end end.join(', ').html_safe end |
#tags_field_tag(object) ⇒ Object
4 5 6 7 |
# File 'app/helpers/my_tags/application_helper.rb', line 4 def (object) html_value = object..blank? ? nil : (object..map(&:name).join(', ') + ', ') text_field_tag "#{object.class.to_s.downcase}[tag_list]", html_value, placeholder: 'Tags', class: 'my_taggable', 'data-tags_list_path' => end |