Module: Linkify::ViewHelper
- Defined in:
- lib/linkify/view_helper.rb
Overview
Contains methods to use in views and helpers.
Instance Method Summary collapse
- #all_models ⇒ Object
- #grouped_options(additional_pages) ⇒ Object
-
#internal_links(current_object, additional_pages = []) ⇒ Object
renders a select.
Instance Method Details
#all_models ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/linkify/view_helper.rb', line 12 def all_models list = [] Dir.foreach("#{::Rails.root}/app/models") do |model_path| # only take .rb files if model_path[-2,2] == "rb" mod = model_path.gsub('.rb', '').camelize.constantize list << mod if mod.linkable end end return list end |
#grouped_options(additional_pages) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/linkify/view_helper.rb', line 24 def (additional_pages) = [] # add additional pages to the list first pages =[] for page in additional_pages pages << page end << ["-", pages] if pages.any? # then, add records from the database for mod in all_models model_array = [] mod.linkable_records.each do |record| model_array << [record.send(mod.linkable_title), [mod.to_s, record.send(mod.linkable_path)]] end << [I18n.t("activerecord.models.#{mod.to_s.underscore}"), model_array] end return end |
#internal_links(current_object, additional_pages = []) ⇒ Object
renders a select
8 9 10 |
# File 'lib/linkify/view_helper.rb', line 8 def internal_links(current_object, additional_pages=[]) ((additional_pages), current_object) end |