Reputation: 3917
I have set up a title instance variable in application_helper.rb, but the base_title does not display in the browser. Can you tell me what's wrong?
application_helper.rb
module ApplicationHelper
# Return a title on a per-page basis
def title
base_title = "Ruby on Rails Tutorial Sample App"
if @title.nil?
base_title
else
"#{base_title} | #{@title}"
end
end
end
application.html.erb
<!DOCTYPE html>
<html>
<head>
<title><%= @title %></title>
<%= csrf_meta_tag %>
</head>
<body>
<%= yield %>
</body>
</html>
Upvotes: 0
Views: 72
Reputation: 16960
In the view you're not actually calling the helper function, it's just trying to output the instance variable (@title), don't prefix a function call with @:
<title><%= title %></title>
Upvotes: 1