E
E
eldar_web2015-08-26 18:35:29
Ruby on Rails
eldar_web, 2015-08-26 18:35:29

How to determine encoding in Ruby on Rails when generating xls file?

I link like this:

<%= link_to 'Скачать excel', exportsub_path(format: "xls") %>

I generate an excel file like this:
def export
 @subscribers = Subscriber.where(user_id: session[:user_id])
     respond_to do |format|
       format.html
       format.xls
  end
end

And in export.xls there is a regular table with a cycle.
So, the excel file loads (with Russian content), but there are kryakozabras. How to solve the problem or how to set the correct encoding?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Román Mirilaczvili, 2015-08-30
@2ord

В контроллере добавить

before_filter :set_charset

    def set_charset
        response.headers["Content-Type"] = "text/html; charset=utf-8"
    end

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question