Ruby On Rails:无法显示Controller#Action视图

时间:2016-10-05 08:08:41

标签: ruby-on-rails

我正在尝试显示我的观点(posts / index.html.erb),但它没有显示出来。

我的routes.rb:

Rails.application.routes.draw do
resources :posts
devise_for :users
root 'posts#index'
end

即使我尝试手动localhost:3000 / posts / index,也没有加载。

它只显示默认值(layouts / application.html.erb):

{一个Bootstrap入门模板 完成预定义的文件路径,您无需更改! Bootstrap v3.3.7 jQuery v1.11.1}

(posts / index.html.erb)应该显示:

<h1>Posts#index</h1>
<p>Find me in app/views/posts/index.html.erb</p>

我缺少什么想法?我还在rails中完成了其他应用程序,并将代码与此应用程序进行了比较,但我无法找出问题所在。

感谢任何帮助!

祝你好运, 柯南

1 个答案:

答案 0 :(得分:1)

我搞定了,忘了&lt;%= yield%&gt;在application.html.erb!