-2

I currently have a helper titled directors_helper.rb with a hash predefined inside of it.

module DirectorsHelper
   def dirs = {
      gm: { pos: "General Manager", email: "123@abc.com" },
      prod: { pos: "Production Director", email: "456@def.com" },
      support: { pos: "Support Director", email: "789@xyz.com" }
   }
   end
end

Anything under the directory /app/views/directors is able to access the content of the helper and thus the hash. Any attempt to call <%= dirs[:gm][:pos] %> inside a directory thats not directors gives me the error undefined local variable or method 'dirs' Is it possible to have my hash globally accessible throughout my project?

jasonsogan
  • 11
  • 1
  • 4
  • Where did you learn to define a `Hash` like that? – Jagdeep Singh Jul 09 '18 at 07:43
  • I picked up a Rails project with only C++ experience... I am going off of code that was already provided to me. Is there another data type that would better suit what I'm trying to accomplish? What's wrong with how it's written? – jasonsogan Jul 12 '18 at 16:49

1 Answers1

0

Turns out it was as simple as going into the controller of the page that I wanted to have access to the directors helper and including helper DirectorsHelper in it.

jasonsogan
  • 11
  • 1
  • 4