Question

I have a problem with my app.

Two stages, same app, same deploy recipes and of course same gems.

In my staging environment everything is ok, in my production environment the HTML is slightly different and this cause to me some rendering issue.

Example.

Staging

<a class="btn red" href="/admin/contents/new?type=News" title="News">News
<i class='fa fa-plus'></i>
</a>
<a class="btn blue" href="/admin/contents/new?type=Article" title="Article">Articolo

Production

<a class="btn red" href="/admin/contents/new?type=News" title="News">News
<i class='fa fa-plus'></i>
</a><a class="btn blue" href="/admin/contents/new?type=Article" title="Article">Articolo

The difference is small, but the problem is that in my production environment I lose all the space between buttons.

The code that generate this button is simple:

.col-md-3
  = link_to new_admin_content_path(type: 'News'), class: "btn red", title: "News" do
    News
    %i.fa.fa-plus
  = link_to new_admin_content_path(type: 'Article'), class: "btn blue", title: "Article" do
    Articolo
    %i.fa.fa-plus

What's the problem???

Was it helpful?

Solution

Here's an excerpt from haml FAQ:

Why is my markup indented properly in development mode, but not in production?

To improve performance, Haml defaults to {Haml::Options#ugly "ugly" mode} in Rails apps running in production.

Link to FAQ itself. To fix this issue, you need to provide Haml with a different option. So, you basically need to implement an initializer with correct setting:

# config/initializers/haml.rb
Haml::Template.options[:ugly] = false
Haml::Template.options[:remove_whitespace] = false

Here's a link to other examples.

List of available options can be found here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top