Module: OutpostHelper

Defined in:
app/helpers/outpost_helper.rb

Instance Method Summary collapse

Instance Method Details

#flash_alert_type(name) ⇒ Object

Public: Maps the standard Rails flash keys (notice, alert) to the appropriate Bootstrap alert class (success, error respectively). Falls back to just returning the passed-in symbol as a string.

name - The flash key as a Symbol.

Examples

<div class="alert alert-<%= flash_alert_type(:notice) %>">
# => <div class="alert alert-success">

Returns String of appropriate CSS class for Bootstrap alerts.



14
15
16
17
18
19
20
21
# File 'app/helpers/outpost_helper.rb', line 14

def flash_alert_type(name)
  name_bootstrap_map = {
    notice: "success",
    alert:  "error"
  }

  name_bootstrap_map[name.to_sym] || name.to_s
end

Public: Place a modal anywhere with a button to toggle it.

options - (Hash) Options to pass into the modal template. Useful for

CSS ID, and modal title.

block - The block that gets captured and rendered inside of the modal.

Returns String of rendered modal and toggle button.



46
47
48
# File 'app/helpers/outpost_helper.rb', line 46

def modal_toggle(options={}, &block)
  render "/outpost/shared/modal", options: options, body: capture(&block)
end

#render_breadcrumbsObject



29
30
31
32
33
# File 'app/helpers/outpost_helper.rb', line 29

def render_breadcrumbs
  if breadcrumbs.present?
    render '/outpost/shared/breadcrumbs', breadcrumbs: breadcrumbs
  end
end

#render_flash_messagesObject



23
24
25
26
27
# File 'app/helpers/outpost_helper.rb', line 23

def render_flash_messages
  if flash.present?
    render '/outpost/shared/flash_messages', flash: flash
  end
end

#render_navigationObject



35
36
37
# File 'app/helpers/outpost_helper.rb', line 35

def render_navigation
  render '/outpost/shared/navigation', current_user: current_user
end