rails를 이용한 Web Application 만들기
1. rails를 이용한 기본 프로젝트 생성
rails blog
2. SQLite3 설치 (on Win32)
1) cd blog (in cmd prompt)
2) http://www.sqlite.org/download.html 에서 Precompiled Binaries For Windows에서 sqlitedll.zip Download.
3) 압축 해제 후, 2개의 파일(def, dll)을 ruby 설치 폴더\bin이나 c:\Windows\System32에 복사함
※ http://www.skorks.com/2009/08/installing-and-using-sqlite-with-ruby-on-windows/
4) gem install sqlite3-ruby --include-dependencies
3. blog 프로젝트를 위한 DB 생성
- cd blog
- rake db:create
4. "Hello, Worlds" 출력
1) ruby script/generate controller home index
2) blog 폴더 내 app\views\home\index.html.erb 파일에서 내용을 지우고 다음과 같이 적임
<h1>hello, world</h1>
3) Web Server의 실행을 위해, 다음을 입력함
ruby script/server
4) In Web browser, 주소창에 http://localhost:3000/home/index를 입력하면 "hello, world"가 보임
5. Default Page 대신 "hello, world" Page 보여 주기
1) rm public/index.html
2) Open config\routes.rb using a edit program, write following 1st line
map.root :controller => "home"
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
* routes.rb : tells Rails how to connect incoming request to controllers and actions.
3) In web-browser, 주소창에 http://localhost:3000를 입력하면 "hello, world"가 보임