0

開発中に正常に動作するRailsアプリがあります。私はRubyMineで開発していますが、Webrickとsqlite3を使用して、ターミナルからテストして実行します(ファイルは、OSXからターミナルでアクセスするUbuntuワークステーションに保存/実行されます)。アプリは変更された Boostrap テンプレートを使用しており、正常に動作します。ここで、本番モードで実行してみました。

これは私がやったことです: Rails のバージョンは 3.2.11 で、ruby-1.9.2-p290 で rvm 1.8.1 を使用しています。

config.logger = Logger.new(STDOUT) in environment/production.rb
config.serve_static_assets = true in environment/production.rb
export RAILS_ENV=production
rake db:migrate (works fine)
rake assets:precompile --trace

次のエラーが表示されます。

peter@fshsweden:/var/www/prod/mackmyra2.dnsalias.com$ rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/home/peter/.rvm/rubies/ruby-1.9.2-p290/bin/ruby /home/peter/.rvm/gems/ruby-1.9.2-p290/bin/rake     assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
Compiled jquery.js  (2ms)  (pid 4521)
Compiled jquery_ujs.js  (0ms)  (pid 4521)
Compiled bootstrap.js  (0ms)  (pid 4521)
Compiled articles.js  (68ms)  (pid 4521)
Compiled lightbox.js  (0ms)  (pid 4521)
Compiled main.js  (0ms)  (pid 4521)
Compiled prettify.js  (0ms)  (pid 4521)
Compiled public.js  (1ms)  (pid 4521)
Compiled small_articles.js  (0ms)  (pid 4521)
Compiled application.js  (142ms)  (pid 4521)
Compiled application.css  (4744ms)  (pid 4521)
rake aborted!
/var/www/prod/mackmyra2.dnsalias.com/app/views/articles/_form.html.erb:6: syntax error, unexpected     ')'
... 'form-horizontal'} ) do |ff| ).to_s); _erbout.concat "\n"
...                               ^
/var/www/prod/mackmyra2.dnsalias.com/app/views/articles/_form.html.erb:45: syntax error, unexpected     keyword_ensure, expecting ')'
/var/www/prod/mackmyra2.dnsalias.com/app/views/articles/_form.html.erb:47: syntax error, unexpected     keyword_end, expecting ')'
  (in /var/www/prod/mackmyra2.dnsalias.com/app/views/articles/_form.html.erb)
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.3/lib/tilt/template.rb:209:in `instance_eval'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.3/lib/tilt/template.rb:209:in `evaluate_source'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.3/lib/tilt/template.rb:144:in `cached_evaluate'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.3/lib/tilt/template.rb:127:in `evaluate'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.3/lib/tilt/template.rb:76:in `render'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in `block in evaluate'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `each'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `evaluate'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:12:in `initialize'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `new'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `block in build_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in `circular_call_protection'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:248:in `build_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in     `cache_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/bundled_asset.rb:16:in `initialize'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `new'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in     `build_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in     build_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.11/lib/sprockets/static_compiler.rb:19:in `block in compile'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:219:in `block in each_logical_path'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:206:in `block (2 levels) in each_file'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each_entry'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:204:in `block in each_file'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each_file'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:217:in `each_logical_path'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.11/lib/sprockets/static_compiler.rb:18:in `compile'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.11/lib/sprockets/assets.rake:56:in `internal_precompile'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.11/lib/sprockets/assets.rake:70:in `block (3 levels) in <top (required)>'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/home/peter/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.11/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/home/peter/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:159:in     `invoke_with_call_chain'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/home/peter/.rvm/gems/ruby-1.9.2-p290/bin/rake:23:in `load'
/home/peter/.rvm/gems/ruby-1.9.2-p290/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile:primary
rake aborted!
Command failed with status (1): [/home/peter/.rvm/rubies/ruby-1.9.2-p290/bi...]
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/file_utils.rb:53:in `block in     create_shell_runner'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `call'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `sh'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/file_utils_ext.rb:40:in `sh'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/file_utils.rb:80:in `ruby'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/file_utils_ext.rb:40:in `ruby'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.11/lib/sprockets/assets.rake:12:in     `ruby_rake_task'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.11/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.11/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in     invoke_with_call_chain'
/home/peter/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:159:in     `invoke_with_call_chain'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/home/peter/.rvm/gems/ruby-1.9.2-p290/bin/rake:23:in `load'
/home/peter/.rvm/gems/ruby-1.9.2-p290/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile

クリーンなレールアプリで上記を実行すると、動作します。しかし、機能していると思っていたアプリでは失敗します。何が間違っているかについての指針を教えてもらえますか?

_form.rb は、simple_form 呼び出しを伴う部分的なものであり、特別なことは何もありません。

(エラーが発生したように見える場所を示すために、ここに示すのは 2 行だけです)

<%= yield :title %>
<%= simple_form_for(@article, :html => {:multipart => true, :class => 'form-horizontal'} ) do |ff| %>

どんな助けでも大歓迎です!

4

1 に答える 1

1

OK、これは私のばかであることが判明しました。数週間前に他のアセットの問題を解決したとき、(config/application.rb で) いじりました。

config.assets.paths << "#{Rails.root}/app/assets"

誤って追加されました(私が推測する必死の動きで)

config.assets.paths << "#{Rails.root}/app"

もちろん、これには app の下のすべてが資産として含まれていましたが、これはひどく間違っていました。

このエラーは、rake assets:precompile を実行するまで表示されませんでした。私はそのコマンドが何をするのかまったくわからなかったので、それがビュー ERB ファイルをアセットとしてコンパイルしようとしていたことはわかりませんでした。

この記事を見つけた後: http://blog.55minutes.com/2012/02/untangling-the-rails-asset-pipeline-part-2-production/ビューファイルが誤って含まれていることに気付きました。パスの問題。

小さなエラーですが、修正するのは非常に困難です。Rails標準の並べ替え。

于 2013-03-21T00:32:03.213 に答える