title: Compiling YAML with ERB and Rails path helpers mixed in
body: <p>I'm working on a navigation helper in my application that compiles the page navigation for the current namespace/controller from a YAML file. My YAML is something like this:</p>
  
  <pre><code>---
  manage:
    - link: &lt;%= manage_clients_path %&gt;
      icon: torsos-all
      label: Clients
    - link: &lt;%= manage_users_path %&gt;
      icon: torso
      label: Users
  </code></pre>
  
  <p>In my helper, I've gone through a couple iterations, but right now I'm with this code:</p>
  
  <pre><code>require 'yaml'
  require 'erb'
  module NavigationHelper
    include Rails.application.routes.url_helpers
  
    def navigation
      unless current_user.nil?
        namepsace = params[:controller].split('/').first
        compiledNav = ERB.new File.read(File.join Rails.root, 'config/navigation.yml')
        nav = YAML.load compiledNav.result
        if nav.has_key?(namepsace) &amp;&amp; !nav[namespace].blank?
          nav[namepsace]
        else
          []
        end
      end
    end
  end
  </code></pre>
  
  <p>Right now, I get an error that manage_clients_path is not defined (<code>undefined local variable or method</code>manage_clients_path' for main:Object<code>), but I can guarentee that it does exist by running</code>rake routes`.</p>
  
  <p>From <code>rake routes</code></p>
  
  <pre><code>$ ./bin/spring rake routes | grep manage_clients
  manage_clients    GET    /manage/clients(.:format)    manage/clients#index     
  </code></pre>