달력

5

« 2024/5 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
2008. 3. 16. 19:20

Eclipse로 루비 개발하기 Ruby2008. 3. 16. 19:20

http://www.ibm.com/developerworks/kr/library/tutorial/os-eclipse-europa3/index.html

Eclipse로 루비 개발하기
RDT(Ruby Development Tools)

http://updatesite.rubypeople.org/release
ruby perspective

RDT는 루비 코드에 적용되는 기본 기능들을 제공하지만 레일스에 최적화되어 있지는 않다. RDT를 만든 개발자들이 Rails 개발자를 위한 도구를 만든 것이 RadRails이다. RadRails는 이클립스에서 레일스의 기능들에 초점을 맞춰 RDT 기반에서 만들어졌다.

RadRails 설치
Aptana
http://update.aptana.com/install/3.2

설치 후에 Help/Aptana Start Page...
"install"을 클릭하면 Aptana는 이미 설치된 Eclipse 업데이트 시스템을 통해 RadRails 플러그인을 설치한다.

설치 후에 Windows > Open Perspective > Others에서 RadRails perspective로 전환할 수 있다.

1. 레일스 프로젝트 생성하기
File > New > Rails Project 선택
- 프로젝트명에 baseball 입력
- Use default location , Generate Rails application skeleton / Create a Mogrel server 체크
- 만일 Mongrel 서버가 설치되어 있지 않다면 Gems(gem install mongrel)을 통해 설치

2. 데이터베이스 설정하기
config/database.yml 파일을 열어서 아래와 같이 편집

# MySQL (default setup). Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql
# On MacOS X:
# gem install mysql -- --include=/usr/local/lib
# On Windows:
# gem install mysql
# Choose the win32 build.
# Install MySQL and put its /bin directory on your path.
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql
database: baseball
username: root
password: password
host: localhost

# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
test:
adapter: mysql
database: baseball_test
username: root
password:
host: localhost

production:
adapter: mysql
database: baseball_production
username: root
password:
host: localhost

3. Data Perspective 사용하기
Window > Perspective > Data
- 데이터베이스의 테이블을 보여주며, 질의를 실행할 수 있다.
- 데이터베이스 개발 퍼스펙티브와 유사하지만 데이터베이스 설정을 위해 database.yml 파일을 사용한다는 점이 다르다.

4. RadRails와 레이크
4.1 기존 스키마로 작업하기
- RadRails 퍼스펙티브 / Rake Tasks에서 "db:schema:dump"를 선택하고 "Go" 버튼 클릭
- db/schema.rb에 덤프가 생성됨
- db:schema:load를 실행하면 반대로 schema.rb 파일의 내용이 데이터베이스에 반영된다.

4.2 RadRails의 레일스 생성기들
- RadRails 퍼스펙티브 / Generators에서 선택

4.2 모델 생성
- Generators에서 model 선택, 인자로 player로 지정, "Go" 클릭

class Player < ActiveRecord::Base
has_many
:games
end

class
Game < ActiveRecord::Base
belongs_to
:player
end

4.3 스캐폴딩
generator에서 scaffold 선택, player를 인자로 지정, "Go"
같은 방법으로 game에 대한 스캐폴딩도 생성

5. 어플리케이션 테스트하기
- 어플리케이션을 띄우기 위해 서버뷰로 이동해서 서버 스타트

:
Posted by codetemplate