-1

I have a problem with accents inside of instance variables in rails 3

controller

class WelcomeController < ApplicationController
  def index
    @tutor="Uriel Hernández"
  end
end

view

<h1>Bienvenido al curso de Ruby on Rails 3</h1>
<h2>Tutor: <%=@tutor  %></h2>
<p>Esta es mi primera vista</p>

Browser

 SyntaxError in WelcomeController#index

/home/fernando/codigofacilito/helloworld/hello_world/app/controllers/welcome_controller.rb:3: invalid multibyte char (US-ASCII)
/home/fernando/codigofacilito/helloworld/hello_world/app/controllers/welcome_controller.rb:3: invalid multibyte char (US-ASCII)
/home/fernando/codigofacilito/helloworld/hello_world/app/controllers/welcome_controller.rb:3: syntax error, unexpected $end, expecting keyword_end
    @tutor="Uriel Hernández"
                        ^
Rails.root: /home/fernando/codigofacilito/helloworld/hello_world
  • just add as a comment `# encoding: UTF-8` at the very first line of your file(s) containing at least one accent – MrYoshiji Mar 30 '15 at 21:08

1 Answers1

0

What version of Ruby are you running?

You might need to specify the #encoding directive at the top of your file.

See: invalid multibyte char (US-ASCII) with Rails and Ruby 1.9

Community
  • 1
  • 1
Cody Caughlan
  • 32,456
  • 5
  • 63
  • 68
  • This answer should be a comment instead (and a duplicate close vote as it has been asked about a thousand times already). – Holger Just Mar 30 '15 at 21:06