Blogモデルをジェネレーターで作成

$ rails generate scaffold Blog title:string description:text
      invoke  active_record
      create    db/migrate/20130827020726_create_blogs.rb
      create    app/models/blog.rb
      invoke    test_unit
      create      test/models/blog_test.rb
      create      test/fixtures/blogs.yml
      invoke  resource_route
       route    resources :blogs
      invoke  scaffold_controller
      create    app/controllers/blogs_controller.rb
      invoke    erb
      create      app/views/blogs
      create      app/views/blogs/index.html.erb
      create      app/views/blogs/edit.html.erb
      create      app/views/blogs/show.html.erb
      create      app/views/blogs/new.html.erb
      create      app/views/blogs/_form.html.erb
      invoke    test_unit
      create      test/controllers/blogs_controller_test.rb
      invoke    helper
      create      app/helpers/blogs_helper.rb
      invoke      test_unit
      create        test/helpers/blogs_helper_test.rb
      invoke    jbuilder
      create      app/views/blogs/index.json.jbuilder
      create      app/views/blogs/show.json.jbuilder
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/blogs.js.coffee
      invoke    scss
      create      app/assets/stylesheets/blogs.css.scss
      invoke  scss
   identical    app/assets/stylesheets/scaffolds.css.scss
migrationを実行

$ rake db:migrate
==  CreateBlogs: migrating ====================================================
-- create_table(:blogs)
   -> 0.0302s
==  CreateBlogs: migrated (0.0303s) ===========================================
Entryモデルにblog_idを追加

$ rails generate migration AddBlogIdToEntry blog_id:integer
      invoke  active_record
      create    db/migrate/20130827021412_add_blog_id_to_entry.rb

$ rake db:migrate
==  AddBlogIdToEntry: migrating ===============================================
-- add_column(:entries, :blog_id, :integer)
   -> 0.0269s
==  AddBlogIdToEntry: migrated (0.0270s) ======================================
Blog-Entryの関連をモデルに定義

has_manyは複数形
belongs_toは単数形
seedデータを記述してDBに投入

$ rake db:migrate:reset
==  CreateEntries: migrating ==================================================
-- create_table(:entries)
   -> 0.0016s
==  CreateEntries: migrated (0.0018s) =========================================

==  CreateBlogs: migrating ====================================================
-- create_table(:blogs)
   -> 0.0012s
==  CreateBlogs: migrated (0.0013s) ===========================================

==  AddBlogIdToEntry: migrating ===============================================
-- add_column(:entries, :blog_id, :integer)
   -> 0.0006s
==  AddBlogIdToEntry: migrated (0.0007s) ======================================

$ rake db:seed
ルーティングを変更してルートをblogs#indexへ変更
blogに紐付いたentryを表示できるようにblog#showを改変
seedファイルにデータを追加してDBに投入しなおし

$ rake db:migrate:reset
==  CreateEntries: migrating ==================================================
-- create_table(:entries)
   -> 0.0016s
==  CreateEntries: migrated (0.0017s) =========================================

==  CreateBlogs: migrating ====================================================
-- create_table(:blogs)
   -> 0.0014s
==  CreateBlogs: migrated (0.0014s) ===========================================

==  AddBlogIdToEntry: migrating ===============================================
-- add_column(:entries, :blog_id, :integer)
   -> 0.0006s
==  AddBlogIdToEntry: migrated (0.0007s) ======================================

$ rake db:seed