Module: Admin::GroupsHelper
- Defined in:
- app/helpers/admin/groups_helper.rb
Instance Method Summary collapse
- #choose_page(object, field, select_options = {}) ⇒ Object
- #message_preview(subject, body, reader) ⇒ Object
- #page_option_branch(page, depth = 0) ⇒ Object
Instance Method Details
#choose_page(object, field, select_options = {}) ⇒ Object
18 19 20 21 22 23 |
# File 'app/helpers/admin/groups_helper.rb', line 18 def choose_page(object, field, ={}) root = Page.respond_to?(:homepage) ? Page.homepage : Page.find_by_parent_id(nil) = page_option_branch(root) .unshift ['<none>', nil] select object, field, , end |
#message_preview(subject, body, reader) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/helpers/admin/groups_helper.rb', line 3 def (subject, body, reader) preview = "From: \#{current_user.name} <\#{current_user.email}>\nTo: \#{reader.name} <\#{reader.email}>\nDate: \#{Time.now.to_date.to_s :long}\n<strong>Subject: \#{subject}</strong>\n\nDear \#{reader.name},\n\n\#{body}\n\n" simple_format(preview) end |
#page_option_branch(page, depth = 0) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'app/helpers/admin/groups_helper.rb', line 25 def page_option_branch(page, depth=0) = [] unless page.title.first == '_' << ["#{". " * depth}#{h(page.title)}", page.id] page.children.each do |child| += page_option_branch(child, depth + 1) end end end |