Module: ScaffoldLogic::MenuHelper

Defined in:
lib/scaffold_logic/menu_helper.rb

Instance Method Summary collapse

Instance Method Details

Returns an admin menu item.

Usage:

menu_item(

:heading => 'Reports',
:url     => admin_reports_path

)

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/scaffold_logic/menu_helper.rb', line 12

def menu_item(args)
  raise ArgumentError, "Missing required values! You must pass a heading and url." unless args[:heading] && args[:url]
  _id = args[:heading].downcase.gsub(/[^a-z]/, '_')
  %{
    <div class="menu_icon" id="#{_id}">
      <h2><a href="#{args[:url]}" title="#{args[:heading]}">#{args[:heading]}</a></h2>
      #{args[:description]}
      <script type="text/javascript">
        Event.observe($('##{_id}'), 'click', function (){ window.location = '#{args[:url]}'; });
      </script>
    </div>
  }.html_safe
end