Rails character encoding issue while using cache

2019-07-23 04:58发布

I am using rails fragemnet cache to cache some html.

Below is my code

  <% if @link.social_tags.present? %>
    <% cache(:action =>'pageui', :action_suffix => "#{@link.id}_tags") do %>
      <% @link.social_tags.each_with_index do |tag, index| %>
        <%= ", " if index > 0 %>
        <%= link_to tag.name, some_path(:tag => tag.id), :title => tag.name, :target => "_blank" %>
      <% end %>
    <% end %>
  <% else %>
    Still no tag for this Page.
  <% end %>

I am getting some weird issue. First time when it doesn't have the fragement cached, it gives error "incompatible character encodings: UTF-8 and ASCII-8BIT"

However subsequent request works fine. Only first request give the error.

Any hint?

0条回答
登录 后发表回答