2013年8月8日木曜日

Head First Rails 4 Chapter2

$ rails new MeBay
$ cd MeBay
$ rails g model ad name:string description:text price:decimal seller_id:integer email:string img_url:string
$ rake db:migrate
$ curl -o db/development.sqlite3 http://www.headfirstlabs.com/books/hfrails/code/development.sqlite3
$ rails g controller ads

app/views/ads/show.html.erb の作成は変更なし
config/routes.rb はコメントを参考に以下のように設定して動作を確認できた。
Rubyらしくより規約に近づいた設定になっている。

MeBay::Application.routes.draw do
  root 'welcome#index'
  get 'ads/:id' => 'ads#show'
end

$ rails server

indexの追加、viewとcontrollerは変更なし
config/routes.rb は下記を追記

get 'ads/' => 'ads#index'

静的コンテンツの配置は仕様が変更になっている。ハマりそうだったので今回はスルー。

0 件のコメント:

コメントを投稿