アプリを Heroku のステージング アプリにデプロイしました。ローカルでは 100% 正常に動作します。
http://exposehair-staging.herokuapp.com
JS をレンダリングする 2 つのコントローラーがあります。リモートフォームを送信すると、意図したアクションが呼び出され、その中でコードが実行されます... ただし、JS テンプレートをレンダリングしていません。アクション内でデータベースの変更が行われていますが、そこでアプリが停止します。JS をレンダリングする両方のコントローラーで発生しています。アプリはローカルの開発モードで正しく動作することに注意してください。
Heroku と連携するためのアプリの構成に問題があるのでしょうか?
Heroku アプリのログは次のとおりです。
2013-02-01T20:17:17+00:00 app[web.1]: Started GET "/" for 68.230.151.152 at 2013-02-01 20:17:17 +0000
2013-02-01T20:17:17+00:00 app[web.1]: Rendered blurbs/_show.html.slim (2.3ms)
2013-02-01T20:17:12+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:10)
2013-02-01T20:17:12+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:10)
2013-02-01T20:17:08+00:00 heroku[web.1]: Starting process with command `bundle exec thin start -R config.ru -e staging -p 23436`
2013-02-01T20:17:15+00:00 app[web.1]: >> Thin web server (v1.5.0 codename Knife)
2013-02-01T20:17:15+00:00 app[web.1]: >> Maximum connections set to 1024
2013-02-01T20:17:15+00:00 app[web.1]: >> Listening on 0.0.0.0:23436, CTRL+C to stop
2013-02-01T20:17:17+00:00 app[web.1]: Completed 200 OK in 232ms (Views: 114.2ms | ActiveRecord: 63.0ms)
2013-02-01T20:17:17+00:00 app[web.1]: Processing by PagesController#index as HTML
2013-02-01T20:17:17+00:00 app[web.1]: Rendered business_hours/_index.html.slim (24.9ms)
2013-02-01T20:17:17+00:00 app[web.1]: Rendered pages/index.html.slim within layouts/application (78.4ms)
2013-02-01T20:17:18+00:00 heroku[router]: at=info method=GET path=/assets/foundation/orbit/left-arrow-5a8ccc07cfa3eae4292d7c705fc7b0a2.png host=exposehair-staging.herokuapp.com fwd=68.230.151.152 dyno=web.1 queue=0 wait=5ms connect=18ms service=32ms status=200 bytes=522
2013-02-01T20:17:18+00:00 heroku[router]: at=info method=GET path=/assets/foundation/orbit/right-arrow-6fca0c667c001b2352c44c9fb1e55528.png host=exposehair-staging.herokuapp.com fwd=68.230.151.152 dyno=web.1 queue=0 wait=2ms connect=7ms service=7ms status=200 bytes=3242
2013-02-01T20:31:22+00:00 heroku[router]: at=info method=GET path=/assets/application-6cd756f9981b294d6c6bd575ae87f94b.css host=exposehair-staging.herokuapp.com fwd=68.230.151.152 dyno=web.1 queue=0 wait=0ms connect=59ms service=15ms status=304 bytes=0
2013-02-01T20:31:22+00:00 heroku[router]: at=info method=GET path=/assets/orbit_05-c6ea9ca2a7468ee90a6c8bfc87eb607e.jpg host=exposehair-staging.herokuapp.com fwd=68.230.151.152 dyno=web.1 queue=0 wait=0ms connect=0ms service=1ms status=304 bytes=0
2013-02-01T20:31:22+00:00 heroku[router]: at=info method=GET path=/assets/orbit_03-42632d5ec29efd0b5e4c8cae7336e47c.jpg host=exposehair-staging.herokuapp.com fwd=68.230.151.152 dyno=web.1 queue=0 wait=0ms connect=0ms service=1ms status=304 bytes=0
2013-02-01T20:31:22+00:00 heroku[router]: at=info method=GET path=/assets/orbit_02-64cae3654d21289ce3fe325715c395ed.jpg host=exposehair-staging.herokuapp.com fwd=68.230.151.152 dyno=web.1 queue=0 wait=0ms connect=2ms service=3ms status=304 bytes=0
2013-02-01T20:31:29+00:00 heroku[router]: at=info method=POST path=/blurbs/1 host=exposehair-staging.herokuapp.com fwd=68.230.151.152 dyno=web.1 queue=0 wait=0ms connect=7ms service=167ms status=500 bytes=643
2013-02-01T20:31:22+00:00 heroku[router]: at=info method=GET path=/assets/application-ca9f839e91c53f606b8c9344a4a1243e.js host=exposehair-staging.herokuapp.com fwd=68.230.151.152 dyno=web.1 queue=0 wait=0ms connect=0ms service=1ms status=304 bytes=0
2013-02-01T20:31:22+00:00 heroku[router]: at=info method=GET path=/ host=exposehair-staging.herokuapp.com fwd=68.230.151.152 dyno=web.1 queue=0 wait=8ms connect=16ms service=148ms status=200 bytes=30683
そして私のgemfile
source 'https://rubygems.org'
ruby '1.9.3'
# Gems required by all environments
gem 'jquery-rails'
gem 'rails', '3.2.9'
gem 'acts-as-taggable-on' # https://github.com/mbleigh/acts-as-taggable-on
gem 'carrierwave' # https://github.com/jnicklas/carrierwave
gem 'combined_time_select', '~> 1.0.0' # https://github.com/excid3/combined_time_select
gem 'fog', '~> 1.3.1' # https://github.com/fog/fog
gem 'font_awesome', '~> 3.0' # https://github.com/balexand/font_awesome
gem 'foundation_rails_helper', # https://github.com/sgruhier/foundation_rails_helper
:git => 'git://github.com/sgruhier/foundation_rails_helper.git',
:branch => 'master'
gem 'mini_magick' # https://github.com/probablycorey/mini_magick
gem 'rack-canonical-host' # https://github.com/tylerhunt/rack-canonical-host
gem 'redcarpet' # https://github.com/vmg/redcarpet
gem 'roboto' # https://github.com/LaunchWare/roboto
gem 'slim-rails' # https://github.com/leogalmeida/slim-rails
gem 'sorcery' # https://github.com/NoamB/sorcery
gem 'stamp' # https://github.com/jeremyw/stamp
gem 'validates_email_format_of' # https://github.com/alexdunae/validates_email_format_of
# Gems requred only for development
group :development, :test do
gem 'better_errors' # https://github.com/charliesome/better_errors
gem 'binding_of_caller' # optional dependancy of better_errors
gem 'sqlite3'
end
# Gems required for heroku
group :staging, :production do
gem 'foreman'
gem 'pg'
gem 'thin'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'coffee-rails', '~> 3.2.1'
gem 'sass-rails', '~> 3.2.3'
gem 'uglifier', '>= 1.0.3'
gem 'compass-rails' # https://github.com/Compass/compass-rails
gem 'zurb-foundation' # http://foundation.zurb.com/docs/
end
application.rb ファイルに次のセットもあります。
config.assets.initialize_on_precompile = false
更新: 要求された関連コードを次に示します。Heroku では js テンプレートはレンダリングされませんが、ローカルで完全に機能します。そのため、最初は省略しました。
一例:
コントローラー/blurbs.rb
class BlurbsController < ApplicationController
before_filter :require_login
# PUT /blurbs/1
def update
@blurb = Blurb.find(params[:id])
respond_to do |format|
if @blurb.update_attributes(params[:blurb])
format.js { }
else
format.js { render 'reload' }
end
end
end
end
ビュー/blurbs/reload.js
# Reload form
$("#editBlurb<%= @blurb.id %> form").html("<%= escape_javascript(render :partial => 'form', :locals => {:blurb => @blurb}) %>")
ビュー/blurbs/_form.html.slim
= form_for blurb, remote: true do |f|
.field
= f.text_area :content, :label => blurb.name.titleize
.actions = f.submit 'Save'