Strange problem with accentuated characters


#1

I have a menu controller that has the configuration for the menus in
my web. Each action is a menu and I have a function “opcion” that
creates options that are stored in an array @opciones this way:
[{:nombre => “name”,:controller => “controller”, :action=>
“action”}…] This array is later used in the view to create link_to
items.
In this code I have the menu “secciones” with three options:

def secciones
@opciones = Array.new
@opciones << opcion(“LifeSTech”,“lst”,“index”)
@opciones << opcion(“Investigacion”,“investigacion”,“index”)
@opciones << opcion(“Publicaciones”,“publicacion”,“index”)
end

private
def opcion(nombre,controller,action)
return {:nombre => nombre, :controller => controller, :action=>
action}
end

In the view “secciones.rhtml” I have:

<% @opciones.each do |opcion| %>
<%= link_to opcion[:nombre], {:controller =>
opcion[:controller],:action => opcion[:action]}, :class =>
“enlaces_contenidos”%>
<% end %>

This works perfectly if I have no accents, but if I use
“Investigacion” instead of “Investigación” it gives me this error:

./script/…/config/…/app/controllers/menu_controller.rb:7: syntax
error, unexpected tIDENTIFIER, expecting ‘)’
@opciones << opcion(“Investigación”,“investigacion”_->parsererror<-
_,“index”)

->parsererror<- marks the point where the parser crashes

The file is ANSI but I’ve tried with UTF-8 and I have not solved the
question. I think the problem is specific to rails 1.2.* because this
code works with accents in 1.1 with this code in the application.rb:

after_filter :set_charset

def set_charset
headers[“Content-Type”] ||= “text/html; charset=iso-8859-1”
end

This code does not work anymore with rails 1.2.

I would appreciate any help.

Thank you