Вопрос

I have an Rails app that is working fine in development. I'm developing it in RubyMine but I test and run it from the Terminal (files are stored/run on a Ubuntu workstation that I access with Terminal from OSX) using Webrick and sqlite3. The app uses a modified Boostrap-template and it works fine. Now I wanted to try to run it in production mode.

This is what I did: Rails version is 3.2.11, I use rvm 1.8.1 with ruby-1.9.2-p290

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

I get the following error:

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

Now if I do the above on a clean rails app, it works. But it fails on my app that I thought was working. Can you give any pointers about what is wrong?

The _form.rb is btw a partial with a simple_form call, nothing special at all.

(Just two lines shown here to show where the error seems to occur)

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

Any help is appreciated!

Это было полезно?

Решение

OK this turned out to be a goof by me. When solving some other asset problem a few weeks ago, I had fiddled around with (in config/application.rb)

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

and accidentally added (In some desperate move I guess)

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

This of course included EVERYTHING under app as assets, which was horribly wrong.

This error did show up until I had to do a rake assets:precompile. Since I didnt really have a clue what that command did, I didn't see that it was trying to compile view ERB files as assets.

After finding this article: http://blog.55minutes.com/2012/02/untangling-the-rails-asset-pipeline-part-2-production/ I realised that it was erroneously including the view files and it had to be a path problem.

Small error but very difficult to fix. Sort of the Rails standard.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top