【问题标题】:Blank pages after converting to rails 4.1转换为 Rails 4.1 后的空白页
【发布时间】:2014-04-17 08:16:03
【问题描述】:

从 rails 3.2 转换到 rails 4.1 后,它会在每个操作上呈现空白页。 只是

Started GET "/" for 127.0.0.1 at 2014-04-17 10:50:59 +0300
Processing by SomeController#index as HTML
Completed 200 OK in 303ms (Views: 0.2ms | ActiveRecord: 1.2ms)

我在配置中遗漏了什么?路线错误?

==== 更新 =====

我在 app/views/some/index.html.erb 中有一个视图 像

这样的代码
somestring code
<script>
  somejscode
</script>

渲染的 html 似乎是空的(chrome addons js 除外):

<html>
  <head>
    <style type="text/css"></style>
  </head>
  <body>
    <pre style="word-wrap: break-word; white-space: pre-wrap;"> </pre>
    <script src="//dl.metabar.ru/static/js/ecomerce-context-sovetnik-vks.js" type="text/javascript" async=""></script>
    <iframe src="https://dl.metabar.ru/static/storage/index.html" style="display: none;"></iframe>
  </body>
</html>

rails 的日志是:

=> Booting Thin
=> Rails 4.1.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop


Started GET "/" for 127.0.0.1 at 2014-04-17 11:24:02 +0300
Processing by SomeController#index as HTML
Completed 200 OK in 262ms (Views: 0.2ms | ActiveRecord: 5.0ms)

==== 更新 ====

布局:

<!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]>    <html class="ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]>    <html class="ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
  <head>
    <meta charset="utf-8" />


    <!-- Set the viewport width to device width for mobile -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <title><%= content_for?(:title) ? yield(:title) : "Untitled" %></title>

    <%= stylesheet_link_tag    "application" %>
    <%= javascript_include_tag "vendor/custom.modernizr" %>
    <%= csrf_meta_tags %>
  </head>

  <body>

    <%= yield %>


    <%= javascript_include_tag "application" %>
  </body>
</html>

==== 更新 ====

似乎它呈现类似于render nothing: true 的东西,因为它呈现[" "]。 我制作了egrep -R "render nothing" .,但没有发现任何帮助。有什么建议吗?

render body: File.read("#{Rails.root}/app/views/some/index.html.erb")

正在工作,但这不是一个好的决定。

【问题讨论】:

  • 当您执行该操作时,您预计会发生什么?
  • 请添加日志内容
  • 但是它渲染了什么?能否提供 Rails 生成的 HTML 代码?
  • @MarekLipka 大量的 js 和 css 代码,并且像 rails 3.2 中通常的那样产出
  • 请添加布局内容。

标签: ruby-on-rails ruby-on-rails-4


【解决方案1】:

好的,伙计们,我已经解决了。 我尝试了很多方法来识别和\或修复这个奇怪的错误,但没有找到。 最后一步是

$ cd ..
$ rails new previous_app_name

并使用d diff 添加 rails4 错过的配置。和n 跳过所有更改。 方法很脏,但是如果你会遇到这样的问题并且会准确地添加或更改行,那么一切都会好起来的;)

【讨论】:

    猜你喜欢
    • 2015-02-02
    • 2011-03-31
    • 1970-01-01
    • 1970-01-01
    • 2022-11-04
    • 2018-02-25
    • 2017-08-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多