我使用Spree在Rails上遇到了非常奇怪的问题。
每个请求都要处理两次。这与AJAX没有问题,因为单个CURL请求也会被处理两次。这也不是日志的问题,因为动作确实发生了两次。
问题仅存在于Heroku和本地的生产环境中。
示例日志:
2014-04-06T06:45:48.969394+00:00 heroku[router]: at=info method=POST path=/spree/api/orders/R657018514/line_items host=xxx.xxx.com request_id=75ac3584-f33e-48fe-b6ce-d898120f8b57 fwd="185.12.21.77" dyno=web.1 connect=0ms service=399ms status=201 bytes=1097
2014-04-06T06:45:48.952672+00:00 app[web.1]: Rendered vendor/bundle/ruby/2.0.0/bundler/gems/spree-78f129b6d6f5/api/app/views/spree/api/orders/show.v1.rabl (120.9ms)
2014-04-06T06:45:48.959453+00:00 app[web.1]: Completed 201 Created in 381ms (Views: 93.4ms | ActiveRecord: 188.8ms)
2014-04-06T06:45:48.959460+00:00 app[web.1]: Completed 201 Created in 381ms (Views: 93.4ms | ActiveRecord: 188.8ms)
2014-04-06T06:45:48.958355+00:00 app[web.1]: Rendered vendor/bundle/ruby/2.0.0/bundler/gems/spree-78f129b6d6f5/api/app/views/spree/api/orders/show.v1.rabl (120.9ms)
Started GET "/" for 127.0.0.1 at 2014-04-06 08:55:29 +0200
Started GET "/" for 127.0.0.1 at 2014-04-06 08:55:29 +0200
Processing by Spree::HomeController#index as HTML
Processing by Spree::HomeController#index as HTML
Rendered spree/home/index.html.erb within spree/layouts/spree_application (0.8ms)
Rendered spree/home/index.html.erb within spree/layouts/spree_application (0.8ms)
Gemfile.rb:
source 'https://rubygems.org'
gem 'rails', '4.0.3'
gem 'newrelic_rpm'
group :assets do
gem 'sass-rails', '~> 4.0.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'compass', '= 0.12.2'
gem 'compass-rails', '~> 1.1.2'
gem 'uglifier', '>= 1.0.3'
end
group :development do
gem 'sqlite3'
gem 'pry-rails'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
gem 'jquery-rails', '~> 3.1.0'
gem 'jquery-ui-rails'
gem 'handlebars_assets'
gem 'spree', :github => "methyl/spree", :require => false
gem 'spree_auth_devise', github: 'spree/spree_auth_devise'
production.rb
Aimer::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = true
config.static_cache_control = "public, max-age=31536000"
# Compress JavaScripts and CSS
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true
# Generate digests for assets URLs
config.assets.digest = true
config.assets.js_compressor = :uglifier
config.assets.css_compressor = :sass
# Defaults to nil and saved in location specified by config.assets.prefix
# config.assets.manifest = YOUR_PATH
# Specifies the header that your server uses for sending files
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = false
# See everything in the log (default is :info)
# config.log_level = :debug
# Prepend all log lines with the following tags
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production
# config.cache_store = :mem_cache_store
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
# config.assets.precompile += %w( search.js )
# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false
# Enable threaded mode
# config.threadsafe!
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
# config.active_record.auto_explain_threshold_in_seconds = 0.5
end
答案 0 :(得分:1)
@Giannis,你是对的,日志只是重复的,并且双重电子邮件的原因在其他地方,可能是在Sendgrid配置中。
答案 1 :(得分:1)
可能您之前使用heroku进行部署,之后您开始使用任何其他实例进行部署。
尝试评论gem 'rails_12factor'
一次并进行捆绑安装,然后检查一次。