I'm trying to run a Ruby on Rails application on my Ubuntu 12.04 server. I have successfully started the Rails server, but when I open it in my browser as localhost:3000
, it shows me the following error:
Encoding::UndefinedConversionError in PagesController#index
"\xC2" from ASCII-8BIT to UTF-8
Rails.root: /home/tarun/tarun-webapp
Application Trace | Framework Trace | Full Trace
app/controllers/application_controller.rb:21:in `jammit'
Request
Parameters:
None
Show session dump
Show env dump
Response
Headers:
None
Here is index method of pages_controller.rb
class PagesController < ApplicationController
layout false
def index
@user_session = UserSession.new
@user = User.new
if current_user
redirect_to user_root_url
end
end
How can I resolve this error?
Most likely LANG=C or locale is unset.
Can also try something like this_should_be_a_unicode_string = this_should_be_a_unicode_string.force_encoding('UTF-8')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.