[英]ArgumentError in MembersController#login invalid byte sequence in US-ASCII
I was trying to set up twitter login system with omuniauth gem and suddenly it happened. 我试图用omuniauth gem设置twitter登录系统,突然间它发生了。 I can't show any page and have the error message below.
我无法显示任何页面,并在下面显示错误消息。 "ArgumentError in MembersController#login invalid byte sequence in US-ASCII" Could you tell me how to solve this problem?
“MembersController中的ArgumentError #USA-ASCII中的登录无效字节序列”你能告诉我如何解决这个问题吗?
And this is the logs in terminal command. 这是终端命令中的日志。
☆terminal command log① ☆终端命令日志①
ArgumentError (invalid byte sequence in US-ASCII):
better_errors (1.0.1) lib/better_errors/error_page.rb:82:in `exception_message'
(erubis:734:in `render'
erubis (2.7.0) lib/erubis/evaluator.rb:65:in `eval'
erubis (2.7.0) lib/erubis/evaluator.rb:65:in `result'
better_errors (1.0.1) lib/better_errors/error_page.rb:25:in `render'
better_errors (1.0.1) lib/better_errors/middleware.rb:96:in `show_error_page'
better_errors (1.0.1) lib/better_errors/middleware.rb:88:in `rescue in protected_app_call'
better_errors (1.0.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (1.0.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (1.0.1) lib/better_errors/middleware.rb:56:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.11) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.11) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.11) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.11) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.11) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.11) lib/rails/engine.rb:479:in `call'
railties (3.2.11) lib/rails/application.rb:223:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.11) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
/Users/aramakikuniharu/.rvm/rubies/ruby-1.9.3- p448/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/aramaki/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/aramaki/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
☆terminal command log ② ☆终端命令日志②
SyntaxError -
/Users/aramaki/railsprojects/miniSNS/app/controllers/application_controller.rb:30:
invalid multibyte char (US-ASCII)
/Users/aramaki/railsprojects/miniSNS/app/controllers/application_controller.rb:30: syntax error, unexpected $end, expecting keyword_end
end
^:
☆application_controller.rb ☆application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery
def logout
session[:user_id] = nil
redirect_to "members/login"
return
end
def login?
if session[:user_id] != nil then
return true
else
return false
end
end
def me? obj = nil
id_num = obj !=nil ? obj.member_id : params[:id].to_i
if session[:user_id] == id_num then
return true
else
return false
end
end
def admin?
Member.find(session[:user_id]).admin
end
def checklogin?
if session[:user_id] != nil then
return true
else
redirect_to '/members/login'
return false
end
end
def checkme? obj = nil
id_num = obj !=nil ? obj.member_id : params[:id].to_i
if session[:user_id] == id_num then
return true
else
redirect_to '/members/' + session[:user_id].to_s
return false
end
end
def checkadmin?
if Member.find(session[:user_id]).admin then
return true
else
redirect_to '/members/' + session[:user_id].to_s
return false
end
end
helper_method :current_user
private
def current_user
@current_user ||= Member.find(session[:user_id]) if session[:user_id]
end
end
Looking at the code in a hex editor shows, that you have a bunch of invisible characters at some points in the code. 查看十六进制编辑器中的代码显示,在代码中的某些点上有一堆不可见的字符。 This happens to me some time when hitting
Alt
+ Space
当我碰到
Alt
+ Space
时,这种情况发生在我身上
If you haven't declared that your ruby source file is UTF-8 Ruby 1.9 tries to treat the file as US-ASCII and cannot parse those (They changed this in Ruby 2.0.0 to UTF-8). 如果您尚未声明您的ruby源文件是UTF-8,则 Ruby 1.9会尝试将该文件视为US-ASCII,并且无法解析这些文件(他们在Ruby 2.0.0中将其更改为UTF-8)。 You should remove all those characters (for example there are 5 invisible characters that are not all spaces after the
end
on line 30), then it should work fine. 你应该删除所有这些字符(例如,在第30行
end
后有5个不可见的字符不是所有空格),那么它应该可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.