3

我为此失去了所有的头发:

我的 Rails 服务器启动正常,但无论向它发出哪个请求(资产和公共内容除外),我都会收到此错误:

ArgumentError in HomeController#index

invalid byte sequence in US-ASCII

使用此框架跟踪(无应用程序跟踪)

better_errors (0.9.0) lib/better_errors/stack_frame.rb:19:in `from_exception'
better_errors (0.9.0) lib/better_errors/error_page.rb:52:in `backtrace_frames'
better_errors (0.9.0) lib/better_errors/middleware.rb:114:in `log_exception'
better_errors (0.9.0) lib/better_errors/middleware.rb:87:in `rescue in protected_app_call'
better_errors (0.9.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (0.9.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (0.9.0) lib/better_errors/middleware.rb:56:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.13) 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.13) 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.13) lib/action_dispatch/middleware/static.rb:63:in `call'
railties (3.2.13) lib/rails/engine.rb:479:in `call'
railties (3.2.13) lib/rails/application.rb:223:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.13) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
/home/augustin/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/home/augustin/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/home/augustin/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

我的团队在 Windows 上工作,并且在他们的平台上运行良好,但是该错误发生在我的 ubuntu 计算机上。到目前为止一切正常,如果我回滚到我的最新提交,它会再次工作,所以错误在合并中。

问题是:

  • 我该如何调试这个问题,因为它不是很冗长?
  • 错误实际上意味着什么?Ascii 是预期的,这不是我们所拥有的,或者 ascii 是被发现的,这不是预期的?
  • 错误更可能出现在应用程序控制器中的 gem 中吗?
  • 有没有办法过滤所有特殊字符以了解它的来源?
  • 还有什么其他信息可以帮助我调试这个?

读数:

随附的:

Gemfile

source 'https://rubygems.org'

gem 'rails', '3.2.13'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

# Database
gem 'pg'

# Database Init
gem 'seed_dump'
# gem "seedbank"

# gem 'active_model_serializers'

# HAML
gem 'haml', '4.0.3'
gem 'html2haml'

# Front-end
gem 'jquery-rails'
gem 'bootstrap-sass', :git => 'git://github.com/thomas-mcdonald/bootstrap-sass.git', :branch => '3'
# gem 'font-awesome-sass-rails'
gem 'font-awesome-rails'
gem 'bootstrap-datepicker-rails'
gem 'jquery-tokeninput-rails' # tag and autocomplete for conversation

# Shared mustache templates for rails 3.
gem 'smt_rails'

# Attachements
gem 'paperclip', '3.4.2'

# Share on Social Network
gem 'social-share-button'

# Jquery Upload File
# gem "jquery.fileupload-rails"
# Map
gem 'mapbox-rails', :git => 'https://github.com/aug-riedinger/mapbox-rails.git'
gem 'leaflet-markercluster-rails'

# Authentication
gem 'bcrypt-ruby', '3.0.1', :require => 'bcrypt'
gem 'devise'
gem 'omniauth'
gem 'omniauth-facebook', "1.4.0"
gem 'oauth2'
gem 'fb_graph'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'coffee-script-source', '1.5.0'    
  gem 'uglifier', '>= 1.0.3'
end

group :development, :test do
  gem 'better_errors'
  gem 'binding_of_caller'
end

platforms :ruby do
  group :development, :test do
    gem 'railroady'
  end
  group :production do
    gem 'aws-sdk'
    gem 'unicorn'
    gem 'newrelic_rpm'
  end
end

# Messaging - Notifications
gem 'simple_form'
gem 'mailboxer'
gem 'pusher'

gem 'amistad'

# Pdf generation
gem 'prawn'
gem 'prawnto'

# Payments
gem 'activemerchant'

# SEO
gem 'dynamic_sitemaps'
gem 'metamagic'

# Static files
gem 'markdown-rails'

谢谢你帮助一个绝望的人...

4

1 回答 1

5

git log所以,git diff <commit_hash> <previous_commit_hash>我最终通过检查历史中的每个提交(

我在助手中有非 ASCII 字符(显然在每次调用时加载):

  def group_currency(group)
    currency = group.currency
    case currency 
    when 'EUR'
      haml_tag "€"
    when 'USD'  
      haml_tag "$"
    when 'GBP'
      haml_tag "£"   
    end

  end 

因此,在文件开头添加它可以解决它:

#encoding: utf-8
module GroupsHelper
...

但是我发现更多的疑问是为什么 Rails 不能在日志中找到并报告出现问题的文件......我为此在 Rails 上创建了一个问题:https ://github.com/rails/rails/issues/ 12041

于 2013-08-27T15:46:18.033 回答