Kaminari generates string instead of html in produ

2019-08-12 17:00发布

问题:

I'm using Rails 4.2.1, Kaminari 0.16.3 and slim as my template language.

In development mode everything is okay. The pagination navigation is generated correctly, but when I run server in production mode, = paginate @articles generates a string instead of html. So it's escape tags and show them like regular text

<span class="page current">1</span><span class="page"><a rel="next" href="/airsoft-blog/airsoft-gadgets-and-ammunition-reviews?page=2">2</a></span><span class="next"><a rel="next" href="/airsoft-blog/airsoft-gadgets-and-ammunition-reviews?page=2">старее</a></span>

It's running on a thin server and Ruby 2.2.1. This happens the first time.

回答1:

Try this (double equal sign):

== paginate @articles

Kaminari generates html, and it should be used as html in the template, not as string, therefor you need either raw or a == to output it.



回答2:

my problem was with config/locales/ru.yml

bad(not working):

 pagination:
  previous: "<span class='glyphicon glyphicon-arrow-left'></span>"

good(work correctly):

 pagination:
  previous: 'older post'

this is not kaminari bug, but only my fault. also now i think it's a bad practice if you add html inside localisation files