我试图在tutorial之后构建Rails博客网站,但我没有看到预期的网页。我做了以下事情:
1)我已将config / routes.rb文件修改为如下所示:
Blogger::Application.routes.draw do
resources :articles
end
2)在db / migrate中,有一个" _create_articles.rb"我已修改为以下内容:
class CreateArticles < ActiveRecord::Migration
def change
create_table :articles do |t|
t.string :title
t.text :body
t.timestamps
end
end
end
在控制台中,我已经定义了&#34;文章&#34;的几个实例。上课,分配&#34;标题&#34;和&#34;身体&#34;属性,并保存,我通过调用&#34; Article.all&#34;在控制台中:
irb(main):001:0> Article.all
Article Load (1.7ms) SELECT "articles".* FROM "articles"
=> #<ActiveRecord::Relation [#<Article id: 1, title: "Sample Article Title", body: "This is the text for my article, woo hoo!", created_at: "2016-06-17 18:18:33", updated_at: "2016-06-17 18:18:33">, #<Article id: 2, title: "This is the second sample article", body: "Text for the second sample article", created_at: "2016-06-17 18:19:35", updated_at: "2016-06-17 18:19:35">, #<Article id: 3, title: "Third article!", body: "Lorem ipsum", created_at: "2016-06-17 18:20:01", updated_at: "2016-06-17 18:20:01">]>
我还使用&#34; rails服务器&#34;启动了Rails服务器。项目目录中的命令。但是,如果我去localhost:3000,我仍然会看到#34;欢迎乘坐&#34;屏幕(如下所示),而我希望此时会看到错误消息&#34;未知操作 - 操作&#39;索引&#39;找不到ArticlesController&#34;。
事实上,我之前一直在教程中,但我已经关闭了所有内容并重新打开它,现在我不再看到我期望的网站或任何错误消息。什么想法可能有什么不妥?
答案 0 :(得分:5)
您需要在public Command(string name, Action<string, User, Channel> action,
bool adminOnly = false, bool modOnly = false, bool ownerOnly = false, bool hasUserCooldown = true,
TimeSpan? cooldown = null, bool allowOtherCommands = false, string description = null)
: this(name, (m, u, c) => { action(m, u, c); return true; },
adminOnly, modOnly, ownerOnly, hasUserCooldown,
cooldown, allowOtherCommands, description)
{
}
文件中设置根页面,以便在开发环境中删除该页面。
routes.rb