升级的Rails 4到Rail 5-现在得到&#34; NoMethodError:未定义的方法`original_exception&#39; for#<actionview :: template :: error:0x007f243ecd5d48>&#34;

时间:2018-04-06 06:04:57

标签: ruby-on-rails ruby-on-rails-5 actionview

如上所述,我通过更新Gemfile中的版本并运行rails app:update将我的Rails从v4更新到v5.1.5。我尝试加载页面时收到以下错误导致服务器崩溃:

    ActionView::Template::Error ($map2: (3rem 2.5rem 2rem 1.5rem 1.25rem 1rem 0.75rem) is not a map for `map-merge'):
    19:     src="https://maps.googleapis.com/maps/api/js?key=<%= ENV["GOOGLE_MAPS_KEY"]%>&callback=initMap"
    20:     type="text/javascript">
    21:    </script>
    22:   <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
    23:   <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
    24:   <%= csrf_meta_tags %>
    25: </head>

app/assets/stylesheets/application.scss:18
app/views/layouts/application.html.erb:22:in `_app_views_layouts_application_html_erb__2123457921920629012_70201480953880'

NoMethodError: undefined method `original_exception' for #<ActionView::Template::Error:0x007fb21c9d6068>
        from /usr/local/rvm/gems/ruby-2.3.4/gems/web-console-2.3.0/lib/web_console/extensions.rb:16:in `block in render_exception_with_web_console'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/web-console-2.3.0/lib/web_console/extensions.rb:3:in `tap'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/web-console-2.3.0/lib/web_console/extensions.rb:3:in `render_exception_with_web_console'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.1.5/lib/action_dispatch/middleware/debug_exceptions.rb:69:in `rescue in call'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.1.5/lib/action_dispatch/middleware/debug_exceptions.rb:58:in `call'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/web-console-2.3.0/lib/web_console/middleware.rb:20:in `block in call'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/web-console-2.3.0/lib/web_console/middleware.rb:18:in `catch'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/web-console-2.3.0/lib/web_console/middleware.rb:18:in `call'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.1.5/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-5.1.5/lib/rails/rack/logger.rb:36:in `call_app'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-5.1.5/lib/rails/rack/logger.rb:24:in `block in call'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.5/lib/active_support/tagged_logging.rb:69:in `block in tagged'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.5/lib/active_support/tagged_logging.rb:26:in `tagged'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.5/lib/active_support/tagged_logging.rb:69:in `tagged'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-5.1.5/lib/rails/rack/logger.rb:24:in `call'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-rails-3.2.1/lib/sprockets/rails/quiet_assets.rb:13:in `call'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.1.5/lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.1.5/lib/action_dispatch/middleware/request_id.rb:25:in `call'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/rack-2.0.4/lib/rack/method_override.rb:22:in `call'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/rack-2.0.4/lib/rack/runtime.rb:22:in `call'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.5/lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.1.5/lib/action_dispatch/middleware/executor.rb:12:in `call'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.1.5/lib/action_dispatch/middleware/static.rb:125:in `call'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/rack-2.0.4/lib/rack/sendfile.rb:111:in `call'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/railties-5.1.5/lib/rails/engine.rb:522:in `call'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/rack-2.0.4/lib/rack/handler/webrick.rb:86:in `service'
        from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
        from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
        from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'
10.240.1.50 - - [06/Apr/2018:06:01:47 UTC] "GET / HTTP/1.1" 500 1477
- -> /
10.240.1.30 - - [06/Apr/2018:06:01:50 UTC] "GET /favicon.ico HTTP/1.1" 200 0
http://traid-emikaijuin.c9users.io/ -> /favicon.ico

我发现了一个类似的帖子,它与默认的application.scss和application.js有关,需要尚未创建的目录,但这不适用于我的情况。

这是application.html.erb的开头:

<!DOCTYPE html>
<html>
<head>
  <title>Workspace</title>

  <link 
    href="https://fonts.googleapis.com/css?family=Raleway:200,400,700,800" 
    rel="stylesheet">
  <script
    src="https://code.jquery.com/jquery-3.3.1.js"
    integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
    crossorigin="anonymous"></script>
  <script 
    defer 
    src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
   <script 
    async 
    defer 
    src="https://maps.googleapis.com/maps/api/js?key=<%= ENV["GOOGLE_MAPS_KEY"]%>&callback=initMap"
    type="text/javascript">
   </script>
  <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
  <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
  <%= csrf_meta_tags %>
</head>

和我的application.scss

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any styles
 * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
 * file per style scope.
 *
 *= require_tree .
 *= require_self
 */
@import "bulma";
@import "bootstrap";

// html {
//     background-color: rgba(107,186,167,0.3);
// }

// body{
// }

2 个答案:

答案 0 :(得分:2)

您的网络控制台上的宝石已过期。

尝试删除Gemfile中的所有版本限制:

gem web-console

然后使用

bundle update web-console

答案 1 :(得分:0)

original_exception 在 Rails 5.1 中更改为 cause。在此处查看提交:https://github.com/rails/rails/commit/b9ba263e5aaa151808df058f5babfed016a1879f

original_exception 替换为 cause 以解决问题。