Beetlejuice
Beetlejuice

Reputation: 4425

rails 3 using iso-8859-1 entire project

I need a project in Rails 3 that is written in iso-8859-1 encoding. The problem is my views. If I put some latin signal in them, it display like a black "?". To solve I have to put #encoding: iso-8859-1 in each view file.

There is a way to tell all the project will be iso-8859-1?

I already try to change Application.rb file, but no success.

Thanks.

Upvotes: 1

Views: 604

Answers (1)

Seamus Abshere
Seamus Abshere

Reputation: 8516

I suggest trying this in config/application.rb (perhaps you tried config.encoding before—see side note)

config.action_controller.default_charset = 'ISO-8859-1'

That should work in both Ruby 1.8 and Ruby 1.9.

Also make sure your HTML layout is synchronized:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

Side note: You should probably leave config.encoding = 'UTF-8' alone. This is especially true for Ruby 1.8, where config.encoding is used to set $KCODE and doesn't like $KCODE = 'NONE', which is what you would have to put for ISO-8859-1.

Upvotes: 1

Related Questions