title: undefined method `[]' for nil:NilClass for a method in application helper
body: <p>I have a method called crumbs that is saying undefined method.  I am importing code from a sinatra app and trying to make it work with a rails app.   </p>
  
  <p>here is the method:  </p>
  
  <pre><code>def crumbs
  primary, secondary = current_link
  return {
      primary:   { icon: menu[primary.to_sym][:primary][:icon], label: menu[primary.to_sym][:primary][:label]},
      secondary: {
          icon:  menu[primary.to_sym][:items][secondary.to_sym][:icon],
          label: menu[primary.to_sym][:items][secondary.to_sym][:label]
      }
  }
  end
  </code></pre>
  
  <p>Here are other methods included within the method: </p>
  
  <pre><code> def menu
    return {
      dashboard: {
          primary: { link: "dashboard", icon: "icon-dashboard", label: "Dashboard" },
          items: {
              dashboard: { icon: "icon-dashboard", label: "Dashboard" }
          }
      },
      ui_lab: {
          primary: { link: "buttons", icon: "icon-beaker", label: "UI Lab" },
          items: {
              buttons: { icon: "icon-hand-up",       label: "Buttons" },
              general: { icon: "icon-beaker",        label: "General elements" },
              icons:   { icon: "icon-info-sign",     label: "Icons"},
              grid:    { icon: "icon-th-large",      label: "Grid"},
              tables:  { icon: "icon-table",         label: "Tables"},
              widgets: { icon: "icon-plus-sign-alt", label: "Widgets"},
          }
      },
      forms: {
          primary: { link: "forms", icon: "icon-edit", label: "Forms" },
          items: {
              forms: { icon: "icon-edit", label: "Form Elements" }
          }
      },
      charts: {
          primary: { link: "charts", icon: "icon-bar-chart", label: "Charts"},
          items: {
              charts: { icon: "icon-bar-chart", label: "Charts"}
          }
      },
      other: {
          primary: { link: "wizard", icon: "icon-link", label: "Others"},
          items: {
              wizard: { icon: "icon-magic", label: "Wizard" },
              login: { icon: "icon-user", label: "Login Page" },
              sign_up: { icon: "icon-user", label: "Sign Up Page" },
              full_calendar: { icon: "icon-calendar", label: "Full Calendar" },
              error404: { icon: "icon-ban-circle", label: "Error 404 page" },
          }
      }
  }
  end
  </code></pre>
  
  <p>As well as this one:</p>
  
  <pre><code>def current_link
  root_path = "/"
  current_route = request.url.split("/") # pages/dashboard/stats.html -&gt; ['dashboard', 'stats.html']
  return current_route.compact.first, current_route.compact.split(".").first
  end
  </code></pre>
  
  <p>In the view this is what is being called:</p>
  
  <pre><code>      &lt;i class="&lt;%= crumbs[:secondary][:icon] %&gt;"&gt;&lt;/i&gt;
          &lt;%= crumbs[:secondary][:label] %&gt;
  </code></pre>
  
  <p>Any ideas?</p>