5

Herokuでホストされている私のWebサイトは、Rails3.2.8で正常に動作しています。静的な(ほとんどの場合)WebページにHighVoltage gemでルート制約クラスを使用しています:routes.rb:

get "/*id" => "high_voltage/pages#show", constraints: Constraints::StaticPage.new

私はファイルを持っています/lib/constraints/static_page.rb

module Constraints
  class StaticPage
    def matches?(request)
      File.exist? file_path(request.path)
    end

    private

    def file_path(view)
      static_page_views_dir.to_s.concat("#{view}.html.erb")
    end

    def static_page_views_dir
      Rails.root.join('app', 'views', 'pages')
    end
  end
end

問題は、Rails 3.2.9にアップデートしてgit push heroku、アプリがクラッシュしたことです:(

my-host:my-site scott$ heroku ps
=== web: `bundle exec rails server -p $PORT`
web.1: crashed 2012/11/14 12:14:41 (~ 2s ago)

Constraints::StaticPageどうやら、Ruby/Herokuは私のクラスを見つけることができません。私はそれrequireを私の一番上に持っていますroutes.rb

require 'constraints/static_page'

Rails 3.2.9で何か変更があり、Herokuで動作しなくなりましたか?ローカルでは、Herokuだけでなく、すべてが正常に機能します。ルートでその制約を取り除くと、すべてが完璧に機能します(これらの制約がないことを除けば)。これが私のheroku logs出力です:

2012-11-14T20:14:36+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2012-11-14T20:14:36+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2012-11-14T20:14:38+00:00 app[web.1]: => Booting WEBrick
2012-11-14T20:14:38+00:00 app[web.1]: => Rails 3.2.9 application starting in production on http://0.0.0.0:18361
2012-11-14T20:14:38+00:00 app[web.1]: => Call with -d to detach
2012-11-14T20:14:38+00:00 app[web.1]: => Ctrl-C to shutdown server
2012-11-14T20:14:38+00:00 app[web.1]: Exiting
2012-11-14T20:14:38+00:00 app[web.1]: /app/config/routes.rb:50:in `block in <top (required)>': uninitialized constant ActionDispatch::Routing::Mapper::Constraints::StaticPage (NameError)
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:282:in `instance_exec'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:282:in `eval_block'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:260:in `draw'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/config/routes.rb:3:in `<top (required)>'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application/routes_reloader.rb:40:in `each'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/lazy_load_hooks.rb:42:in `each'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application/finisher.rb:52:in `block in <module:Finisher>'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application/routes_reloader.rb:40:in `load_paths'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/devise-2.1.2/lib/devise/rails.rb:14:in `block in <class:Engine>'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application/routes_reloader.rb:16:in `reload!'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application.rb:108:in `reload_routes!'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/lazy_load_hooks.rb:34:in `call'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:55:in `block in run_initializers'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `run_initializers'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/config/environment.rb:5:in `<top (required)>'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/railtie/configurable.rb:30:in `method_missing'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/config.ru:4:in `block in <main>'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application.rb:136:in `initialize!'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `each'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `run'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/config.ru:1:in `new'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `instance_exec'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:50:in `tap'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:50:in `<top (required)>'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/config.ru:1:in `<main>'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands/server.rb:46:in `app'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands/server.rb:70:in `start'
2012-11-14T20:14:38+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:55:in `block in <top (required)>'
2012-11-14T20:14:38+00:00 app[web.1]:   from script/rails:6:in `require'
2012-11-14T20:14:38+00:00 app[web.1]:   from script/rails:6:in `<main>'
2012-11-14T20:14:40+00:00 heroku[web.1]: Process exited with status 1
2012-11-14T20:14:40+00:00 heroku[web.1]: State changed from starting to crashed
4

1 に答える 1

3

Gemfileで次のバージョンを試すことができますか?

# Gemfile
gem 'rails', '3.2.9'
gem 'high_voltage', '~> 1.2.1'
gem 'thin'

# ...

High Voltageの1.2.1リリースには、ルートルートの制約が組み込まれています。これにより、ファイルからルートを完全に削除できconfig/routes.rbます。

高電圧用の初期化子を設定するだけです。

# config/initializers/high_voltage.rb
HighVoltage.route_drawer = HighVoltage::RouteDrawers::Root

上記をHerokuのCedarアプリにデプロイしたところ、期待どおりに実行されました。

于 2012-11-14T21:22:05.183 に答える