Reputation: 57551
I'm trying to build Rails blogger site following a tutorial, but I'm not seeing the expected web page. I've done the following:
1) I've modified the config/routes.rb file to look as follows:
Blogger::Application.routes.draw do
resources :articles
end
2) In db/migrate, there is a "_create_articles.rb" which I've modified to the following:
class CreateArticles < ActiveRecord::Migration
def change
create_table :articles do |t|
t.string :title
t.text :body
t.timestamps
end
end
end
In the console, I've defined several instances of the "Article" class, assigned "title" and "body" attributes, and saved them, which I confirmed by calling "Article.all" in the console:
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">]>
I've also started the Rails server using the "rails server" command in project directory. However, if I go to localhost:3000 I still see the "Welcome aboard" screen (shown below), whereas I would expect at this point to see an error message "Unknown action - The action 'index' could not be found for ArticlesController".
In fact, I have been at this point before in the tutorial, but I've since closed everything and reopened it, and now I no longer see the website I expect, or any error message. Any ideas what could be amiss?
Upvotes: 0
Views: 127
Reputation: 11813
You need to set a root page in your routes.rb
file to get rid of that page in development environment.
Blogger::Application.routes.draw do
resources :articles
root 'articles#index'
end
Upvotes: 5