レイルに乗ってみた〜Rails of Ruby on Rails その01「はじめてみる」
[訂正] はてな記法を間違い、単独で表示されなくなってたのを修正。正『||<』、誤『|<<』
Rails2.1とCabon Emacsで
書籍はRails2.0対応で開発環境はNetBeansですが、Rails2.1とCabon Emacsでやってみる(MacOSX10.4)。
- その問題点・補足など
- 見事につまずきまくり(´・ω・`)。
- Rails2.0->2.1の非互換性が思いのほか大きくて吃驚(||゚Д゚)。
- 上記理由?により書籍と順序が若干入れ替わっていたり(データベース作成あたり)
- http://railsofrubyonrails.com/のサンプル動かなかったし(つдT)
- Webアプリとか何なのか知識足りていない自分...(´・ω・`)
- Rubyをほとんど理解してない自分...(||゚Д゚)
- 不安材料山積みですが...
やり遂げます...たぶん
開発環境構築
『Ruby』と『Ruby on Rails』『Carbon Emacs』をインストール
(過去のエントリーとか参照 MacPortsでRubyとかRailsなどインストールしてみた - 牌語備忘録 - pygoとか)
Chapter 02 プロジェクト作成
~ $ cd work
~/work $ rails locus
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create db
create doc
create lib
create lib/tasks
create log
create public/images
create public/javascripts
create public/stylesheets
create script/performance
create script/process
create test/fixtures
create test/functional
create test/integration
create test/unit
create vendor
create vendor/plugins
create tmp/sessions
create tmp/sockets
create tmp/cache
create tmp/pids
create Rakefile
create README
create app/controllers/application.rb
create app/helpers/application_helper.rb
create test/test_helper.rb
create config/database.yml
create config/routes.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/new_rails_defaults.rb
create config/boot.rb
create config/environment.rb
create config/environments/production.rb
create config/environments/development.rb
create config/environments/test.rb
create script/about
create script/console
create script/dbconsole
create script/destroy
create script/generate
create script/performance/benchmarker
create script/performance/profiler
create script/performance/request
create script/process/reaper
create script/process/spawner
create script/process/inspector
create script/runner
create script/server
create script/plugin
create public/dispatch.rb
create public/dispatch.cgi
create public/dispatch.fcgi
create public/404.html
create public/422.html
create public/500.html
create public/index.html
create public/favicon.ico
create public/robots.txt
create public/images/rails.png
create public/javascripts/prototype.js
create public/javascripts/effects.js
create public/javascripts/dragdrop.js
create public/javascripts/controls.js
create public/javascripts/application.js
create doc/README_FOR_APP
create log/server.log
create log/production.log
create log/development.log
create log/test.log
~/work $
スキャッフォールドジェネレータを実行
~/work $ cd locus/
~/work/locus $ ls
README app db lib public test vendor
Rakefile config doc log script tmp
~/work/locus $ script/generate scaffold entry title:string content:text
exists app/models/
exists app/controllers/
exists app/helpers/
create app/views/entries
exists app/views/layouts/
exists test/functional/
exists test/unit/
exists public/stylesheets/
create app/views/entries/index.html.erb
create app/views/entries/show.html.erb
create app/views/entries/new.html.erb
create app/views/entries/edit.html.erb
create app/views/layouts/entries.html.erb
create public/stylesheets/scaffold.css
create app/controllers/entries_controller.rb
create test/functional/entries_controller_test.rb
create app/helpers/entries_helper.rb
route map.resources :entries
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/entry.rb
create test/unit/entry_test.rb
create test/fixtures/entries.yml
create db/migrate
create db/migrate/20080908010337_create_entries.rb
~/work/locus $
Chapter 03 ブログの作成 マイグレーションを実行しデータベース作成
~/work/locus $ rake db:migrate (in /Users/username/work/locus) == 20080908010337 CreateEntries: migrating ==================================== -- create_table(:entries) -> 0.0129s == 20080908010337 CreateEntries: migrated (0.0133s) ===========================
ブラウザでhttp://localhost:3000/entriesを確認(注意!entryが複数形のentriesになる)
New entryで2つ3つ作ったり削除したりしてみる

