I am using HAML in my RoR application.
I have the below code in my Welcome controller:
def index
render :layout => 'homepage'
@qotd = 'Today is Sunday'
end
In my index.html.haml file I am using:
%h1
= @qotd
But in the output, I just see empty h1 tags, without the value of the variable qotd.
Wonder what am I doing wrong.
When you call
renderbefore the@qotdassignment, you’re telling the template to render, and then you’re making the@qotdassignment. When the template renders,@qotddoesn’t exist yet. Swap those two lines in your action.