I am very new to Rails, and am trying to learn how the /lib/
directory in Rails works - and how to reference variables defined in the /lib/
directory for use in a view.
I have a file called helloworld.rb
and it's saved in the /lib/ directory in Rails.
The helloworld.rb
file has the following code:
module HelloWorld
def hello
@howdy = "Hello World!"
end
end
I want to be able to display the results of this method on a view called index.html.erb
, so I include the following code in the index_helper.rb
file:
module IndexHelper
require 'helloworld'
end
Also, I include the following code on the view index.html.erb
:
<%= @howdy %>
What am I missing?