第一个轨道应用程序:ROUTES.RB不会导致右页(?)



如果这是基本的,我可能不应该在此处发布。我什至不确定标题是否真的描述了问题。我刚刚开始在Rails上查看Ruby,并关注此页面以设置"我的第一个应用程序":http://guides.rubyonrails.org/getting_started.html

现在,当我到达添加

的点时
root 'welcome#index'

进入路由。RB文件并尝试访问它,这一切都出错了。首先,我认为这是一个许可问题,但是我可以直接在浏览器中访问视图/布局/wellow/index.html.erb文件。

我对此非常陌生,以至于我还没有足够的时间来知道我在故障排除中寻找的东西,因此这篇文章。

启动Rails Server时,我确实会在重新启动和挂起信号时得到看起来像错误的内容,但我怀疑这是问题所在。在此处列出的输出以防万一。

=> Booting Puma
=> Rails 5.1.2 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 3.9.1 (ruby 2.3.3-p222), codename: Private Caller
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop

加载根页面给出以下服务器输出:

Started GET "/" for 127.0.0.1 at 2017-06-28 13:17:23 +0200
Processing by WelcomeController#index as HTML
  Rendering welcome/index.html.erb within layouts/application
  Rendered welcome/index.html.erb within layouts/application (13.0ms)
Completed 500 Internal Server Error in 3742ms

ActionView::Template::Error (TypeError: Object doesn't support this property or method):
     5:
     6:     <%= csrf_meta_tags %>
     7:
     8:     <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
     9:     <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
    10:
    11:     </head>
app/views/layouts/application.html.erb:8:in `_app_views_layouts_application_html_erb___750167210_57076860'

在我看来,它看起来确实加载了索引页面,但是其他一些触发器,并将其重定向到不起作用的页面。该页面的内容指向(视图/布局/application.html.erb(为:

<!DOCTYPE html>
<html>
  <head>
    <title>Blog</title>
    <%= csrf_meta_tags %>
    <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
    </head>
  <body>
    <%= yield %>
  </body>
</html>

路由的内容。

Rails.application.routes.draw do
  get 'welcome/index'
  root 'welcome#index'
  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end

添加/assets/stylesheets/application.css

中的以下行
/*
 * 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
 */

最新更新