./configure --prefix=/opt/ruby1.8gemのインストール
make
make install
ruby setup.rbデプロイ
/opt/ruby1.8.6/bin/gem install rails
Bulk updating Gem source index for: http://gems.rubyforge.org
Successfully installed rake-0.8.1
Successfully installed activesupport-2.0.2
Successfully installed activerecord-2.0.2
.......
....(続く)
rails rails_app -d mysqlmongrelサーバをインストール
rake db:create
gem install mongrelmobgrelサーバの起動
Building native extensions. This could take a while...
Building native extensions. This could take a while...
Successfully installed gem_plugin-0.2.3
Successfully installed daemons-1.0.9
....(続く)
[root@centos rails_app]# mongrel_rails startcontrollerの生成
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart).
** Rails signals registered. HUP => reload (without restart). It might not work well.
** Mongrel 1.1.3 available at 0.0.0.0:3000
** Use CTRL-C to stop.
script/generate controller helloscaffoldの実行
script/generate scaffold book title:string price:intgerDBを作成
exists app/models/
exists app/controllers/
exists app/helpers/
create app/views/books
exists app/views/layouts/
exists test/functional/
exists test/unit/
create app/views/books/index.html.erb
create app/views/books/show.html.erb
create app/views/books/new.html.erb
create app/views/books/edit.html.erb
create app/views/layouts/books.html.erb
create public/stylesheets/scaffold.css
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/book.rb
create test/unit/book_test.rb
create test/fixtures/books.yml
create db/migrate
create db/migrate/001_create_books.rb
create app/controllers/books_controller.rb
create test/functional/books_controller_test.rb
create app/helpers/books_helper.rb
route map.resources :books
rake db:migrateDBの状態を戻したい場合
(in /var/www/rails_app)
== 1 CreateBooks: migrating ===================================================
-- create_table(:books)
-> 0.1500s
== 1 CreateBooks: migrated (0.1504s) ==========================================
rake db:migrate VERSION=0DBの内容を更新したい場合
script/generate migration add_column ←実行したい内容にそった名前にするのが良い。db/migrateに002_add_column.rbのようなファイルが出来る。
script/destroy migration add_columnDB更新
rake db:migratetableを追加
# script/generate model userscript/generateのオプションについて
script/destroy scaffold source2 filename:string content:stringrails対話モード
# script/consoleroutesの確認
# rake routes参考URL
(in /var/www/rails/code_viewer)
roles GET /roles {:controller=>"roles", :action=>"index"}
formatted_roles GET /roles.:format {:controller=>"roles", :action=>"index"}
POST /roles {:controller=>"roles", :action=>"create"}
POST /roles.:format {:controller=>"roles", :action=>"create"}
new_role GET /roles/new {:controller=>"roles", :action=>"new"}
formatted_new_role GET /roles/new.:format {:controller=>"roles", :action=>"new"}
edit_role GET /roles/:id/edit {:controller=>"roles", :action=>"edit"}
formatted_edit_role GET /roles/:id/edit.:format {:controller=>"roles", :action=>"edit"}
role GET /roles/:id {:controller=>"roles", :action=>"show"}
formatted_role GET /roles/:id.:format {:controller=>"roles", :action=>"show"}
...(続く)
http://kapi.jp/kapi_blog/118
2008年02月15日
関連カテゴリ Ruby on Rails