In a Rails 3.2 app I define the page title using <% title "Title Text" %>.
This is passed to the <title> tag as follows:
<head>
<title>AppName | <%= yield (:title) || "Default Title" %></title>
</head>
and rendered as follows:
<h1><%= yield(:title) %></h1>
by the following helper method:
def title(page_title, show_title = true)
content_for(:title) { h(page_title.to_s) }
@show_title = show_title
end
def show_title?
@show_title
end
This works as expected in development, and works in most cases in production on Heroku.
In a few places I have more complex titles, e.g. <% title ["Edit ",(@model.name)] %>.
This works as expected in development, and displays Edit Foo Bar.
But on Heroku this is rendered as ["Edit ", "Foo Bar"].
Why is the syntax being rendered on Heroku? I have a feeling that this may be related to using square brackets to define an array, but after searching the Heroku docs and Google I haven’t found any information about this.
Thanks for any ideas to help.
It sounds like you’re using Ruby 1.8 at home while Heroku is using 1.9 —
Array#to_sgives different results between the two. To avoid the ambiguity, it’s best to be explicit about how you want arrays to be printed. For example, if you want your title helper to handle arrays specially, something like this should work: