5

I just passed my application in his production environment :

  • debian
  • nginx
  • unicorn
  • mysql

In development I use :

  • mac osx 10.7.3
  • webrick
  • sqlite

I got an error when I go to a view with some UTF-8 chars :

ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT):
    1: render renderer_for(:new)
  app/admin/projects.rb:122:in `block (2 levels) in <top (required)>'

I have added this at the top of my file :

# encoding: utf-8

It make it work in my development environment but not in my production envirnoment, any idea ?

EDIT

The error come from here :

f.has_many :roles do |app_f|
  app_f.inputs do
    # if object has id we can destroy it
    if app_f.object.id
      app_f.input :_destroy, :as => :boolean, :label => "Supprimer l'utilisateur du projet"
    end
    app_f.input :user,      :include_blank => false, :label_method => :to_label
    app_f.input :role_name, :include_blank => false 
    #app_f.input :role_level, :label => 'Author type',  :as => :select, :include_blank => false, :collection => Role::role_list
  end
end

It doesn't change anything if I change the current locale.

EDIT

I'm using ruby 1.9.3 and rails 3.1.0 I have no view to show because I'm using the ActiveAdmin DSL

Awea
  • 3,163
  • 8
  • 40
  • 59

3 Answers3

2

I change mysql in my Gemfile by mysql2

And it work :)

Awea
  • 3,163
  • 8
  • 40
  • 59
0

I found 2 Questions about your question have you seen this questions i hope the answers can help to solve your problem. :)

Question 1 Question 2

Community
  • 1
  • 1
bulleric
  • 2,077
  • 6
  • 21
  • 36
  • Is the line 122 the line with then label tag ? i think you got a problem with the special charakter > ' < (apostroph) test it remove your label tag. – bulleric Mar 01 '12 at 12:35
  • No problem with this character, just a fuc***g problem with the mysql gem :) – Awea Mar 01 '12 at 14:31
0

You didn't tell which Ruby verison you use. And you have to show the view code.

Encoding management is hard, and Ruby/Rails is no exception.

There are some great articles by Yehuda Katz and JEG2 about encoding and how Rails does it.

jlecour
  • 2,905
  • 1
  • 25
  • 24
  • I dont know why but the error line correspondig to a line without any string – Awea Feb 29 '12 at 15:25
  • 1
    There is no view code, i'm using ActiveAdmin and is internal DSL for my views. I solved my problem by change mysql to mysql2 in my gemfile – Awea Mar 02 '12 at 09:36
  • OK that makes sense since "mysql" is unable to hold encoding metadata, but mysql2 is. I remeber having read something about this kind of issue elsewhere. – jlecour Mar 02 '12 at 15:25