3

我有一个关于 Rails 3.2 的项目。我也使用 haml 作为我的模板引擎,但我决定使用 slim 而不是 haml。所以我用 slim 重写了一些视图。但是当我将此更改推送到服务器时,我在生产中遇到了奇怪的错误。

该错误仅出现在使用 slim 作为模板引擎的页面上。在我的开发机器上,页面打开得很好。为了设置服务器,我使用了 Rayan Byte 的截屏视频

我该如何解决?

错误

Started GET "/" for 128.69.76.116 at 2013-04-12 11:19:31 +0000

Started GET "/ru/articles" for 128.69.76.116 at 2013-04-12 11:19:31 +0000
Processing by ArticlesController#index as HTML
  Parameters: {"locale"=>"ru"}
Completed 500 Internal Server Error in 180ms

ActionView::MissingTemplate (Missing template articles/index, application/index with {:locale=>[:ru], :formats=>[:html], :handlers=>[:erb, :builder, :haml]}. Searched in:
  * "/home/deployer/apps/Chirch_app/releases/20130412101936/app/views"
  * "/home/deployer/apps/Chirch_app/shared/bundle/ruby/1.9.1/gems/gmaps4rails-1.5.6/app/views"
  * "/home/deployer/apps/Chirch_app/shared/bundle/ruby/1.9.1/gems/kaminari-0.14.0/app/views"
  * "/home/deployer/apps/Chirch_app/shared/bundle/ruby/1.9.1/gems/devise-2.1.2/app/views"
):
  actionpack (3.2.8) lib/action_view/path_set.rb:58:in `find'
  actionpack (3.2.8) lib/action_view/lookup_context.rb:109:in `find'
  actionpack (3.2.8) lib/action_view/renderer/abstract_renderer.rb:3:in `find_template'
  actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:34:in `determine_template'
  actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:10:in `render'
  actionpack (3.2.8) lib/action_view/renderer/renderer.rb:36:in `render_template'
  actionpack (3.2.8) lib/action_view/renderer/renderer.rb:17:in `render'
  actionpack (3.2.8) lib/abstract_controller/rendering.rb:110:in `_render_template'
  actionpack (3.2.8) lib/action_controller/metal/streaming.rb:225:in `_render_template'
  actionpack (3.2.8) lib/abstract_controller/rendering.rb:103:in `render_to_body'
  actionpack (3.2.8) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
  actionpack (3.2.8) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
  actionpack (3.2.8) lib/abstract_controller/rendering.rb:88:in `render'
  actionpack (3.2.8) lib/action_controller/metal/rendering.rb:16:in `render'
  actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
  activesupport (3.2.8) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
  /home/deployer/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
  activesupport (3.2.8) lib/active_support/core_ext/benchmark.rb:5:in `ms'
  actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
  actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
  activerecord (3.2.8) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
  actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:39:in `render'
  actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
  actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
  actionpack (3.2.8) lib/abstract_controller/base.rb:167:in `process_action'
  actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  activesupport (3.2.8) lib/active_support/callbacks.rb:436:in `_run__609582508__process_action__934117167__callbacks'
  activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.8) lib/abstract_controller/callbacks.rb:17:in `process_action'
  actionpack (3.2.8) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
  activesupport (3.2.8) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  actionpack (3.2.8) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
  activerecord (3.2.8) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (3.2.8) lib/abstract_controller/base.rb:121:in `process'
  actionpack (3.2.8) lib/abstract_controller/rendering.rb:45:in `process'
  actionpack (3.2.8) lib/action_controller/metal.rb:203:in `dispatch'
  actionpack (3.2.8) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  actionpack (3.2.8) lib/action_controller/metal.rb:246:in `block in action'
  actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `call'
  actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
  actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:36:in `call'
  journey (1.0.4) lib/journey/router.rb:68:in `block in call'
  journey (1.0.4) lib/journey/router.rb:56:in `each'
  journey (1.0.4) lib/journey/router.rb:56:in `call'
  actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:600:in `call'
  warden (1.2.1) lib/warden/manager.rb:35:in `block in call'
  warden (1.2.1) lib/warden/manager.rb:34:in `catch'
  warden (1.2.1) lib/warden/manager.rb:34:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.4) lib/rack/etag.rb:23:in `call'
  rack (1.4.4) lib/rack/conditionalget.rb:25:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/head.rb:14:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/flash.rb:242:in `call'
  rack (1.4.4) lib/rack/session/abstract/id.rb:210:in `context'
  rack (1.4.4) lib/rack/session/abstract/id.rb:205:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/cookies.rb:339:in `call'
  activerecord (3.2.8) lib/active_record/query_cache.rb:64:in `call'
  activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `_run__319658905__call__322020128__callbacks'
  activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.8) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.4) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.4) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.4) lib/rack/lock.rb:15:in `call'
  rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
  rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
  rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
  rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
  rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
  railties (3.2.8) lib/rails/engine.rb:479:in `call'
  railties (3.2.8) lib/rails/application.rb:223:in `call'
  railties (3.2.8) lib/rails/railtie/configurable.rb:30:in `method_missing'
  unicorn (4.5.0) lib/unicorn/http_server.rb:552:in `process_client'
  unicorn (4.5.0) lib/unicorn/http_server.rb:628:in `worker_loop'
  unicorn (4.5.0) lib/unicorn/http_server.rb:500:in `spawn_missing_workers'
  unicorn (4.5.0) lib/unicorn/http_server.rb:511:in `maintain_worker_count'
  unicorn (4.5.0) lib/unicorn/http_server.rb:277:in `join'
  unicorn (4.5.0) bin/unicorn:121:in `<top (required)>'
  /home/deployer/apps/Chirch_app/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `load'
  /home/deployer/apps/Chirch_app/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `<main>'

宝石文件

source 'https://rubygems.org'

gem 'rails', '3.2.13'
gem 'pg', '0.15.1'                                                                                  
gem 'jquery-rails', '2.2.1'                                                                         
gem 'haml', '4.0.2'                                                                                 
gem 'therubyracer', :platform => :ruby
gem 'devise', '2.2.3'                                                                               
gem 'simple_form', '2.1.0'                                                                          
gem 'bootstrap-wysihtml5-rails', "0.3.1.19"                                                         
gem 'kaminari', '0.14.0'                                                                            
gem "cancan", '1.6.9'                                                                               
gem "carrierwave", '0.8.0'                                                                          
gem "rmagick", '2.13.2'                                                                             
gem 'gmaps4rails', '1.5.6'                                                                          
gem 'unicorn', '4.6.2'                                                                              
gem 'capistrano', '2.14.2'                                                                          
gem 'less-rails', '2.3.2'                                                                           
gem 'slim', '1.3.8'
gem 'haml2slim'

group :assets do
  gem 'sass-rails',   '~> 3.2.4'
  gem 'coffee-rails', '~> 3.2.2'
  gem 'twitter-bootstrap-rails', '2.2.6'                                                            
  gem 'uglifier', '>= 1.2.3'
end

group :development do
  gem 'annotate', '~> 2.5.0'
  gem 'better_errors'                                                                               
  gem 'binding_of_caller'                                                                           
  gem 'brakeman'                                                                                    
  gem 'meta_request'                                                                                
end

group :development, :test do
  gem 'rspec-rails', '2.13.0'
  gem 'rb-fsevent'                                                                                  
  gem 'guard-rspec', '2.5.2'                                                                        
  gem 'terminal-notifier-guard'                                                                     
  gem 'launchy'                                                                                     
end

group :test do
  gem 'capybara', '2.1.0'                                                                           
  gem 'factory_girl_rails', '4.2.1'                                                                 
  gem 'database_cleaner', '0.9.1'
  gem 'selenium-webdriver', '2.32.1'                                                                
end
4

2 回答 2

6

我发现了问题。经过长时间的研究(独角兽和 ngingx 重启没有帮助),我只是重新启动了整个操作系统,然后该Slim页面出现了。

于 2013-04-13T15:51:47.047 回答
0

看错误,模板句柄还是haml

:formats=>[:html], :handlers=>[:erb, :builder, :haml]}

我的猜测是你的index页面包括一些用haml写的部分,从而带来了混乱。本地开发机器可能在浏览器中有一些缓存,因此那里没有问题。

你把所有的haml模板变成slim怎么样,删除所有的haml模板(使用git rm),haml从Gemfile中删除gem,然后再试一次?

于 2013-04-12T11:32:17.020 回答