본문 바로가기

2008년 6월 이전의 기록/Development

레일즈 2.0.2 업데이트 후 마주친 문제

한동안 레일즈를 쓰지 않다가
프로토타이핑을 할 일이 생겨 다시 레일즈를 펼쳐보게 되었다.

새로 시작하기 전, 업데이트를 받고 시작해야겠다고 판단,

C:\>gem update rails --include-dependencies

어랏, 뭔가 업데이트가 되는걸

...
Successfully installed rails-2.0.2
Gems: [rails] updated
...

잠시 놓고 있던 까닭에 레일즈가 2.x 대로 올라간 것도 모르고 있었다.(-_-)

뭐 크게 달라진 게 있으려나 싶어 그냥 바로 레일즈 프로젝트를 생성

C:\prototypes\rails>rails myapp

MySQL에 데이터베이스를 하나 만들고, 데이터베이스 세팅을 위해 config/database.yml을 열고... 그런데... 뭔가 이상하다.

# SQLite version 3.x
#   gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
  adapter: sqlite3
  database: db/development.sqlite3
  timeout: 5000

# 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: sqlite3
  database: db/test.sqlite3
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  timeout: 5000

MySQL 세팅 정보가 있어야 하는데
SQLite3 세팅 정보가 나와 있다.

관련 정보를 검색해 보니, Rails 2는 SQLite3가 기본 데이터베이스로 지정되어 있다고 한다.
Ruby On Rails 블로그에 실려 있는 내용을 보자.

SQLite3 is the new default database

Most importantly is SQLite3 as the new database we’ll configure for by default when you run the rails generation command without any specification. This change comes as SQLite3 is simply an easier out of the box experience than MySQL. There’s no fussing with GRANTs and creates, the database is just there. This is especially so under OS X 10.5 Leopard, which ships with SQLite3 and the driver gems preinstalled as part of the development kit.

If you want to preconfigure your database for MySQL (or any of the other adapters), you simply do “rails -d mysql myapp” and everything is the same as before. But if you’re just playing with a new application or building a smallish internal tool, then I strongly recommend having a look at SQLite3. Thanks to the agnostic db/schema.rb, it’s as easy as changing your config/database.yml to switch from SQLite3 to MySQL (or another database) as soon as your load warrants it.

(출처 : Rails 2.0.2: Some new defaults and a few fixes )

위 자료에 따르면 평상시와 같이 MySQL을 사용하고 싶으면

rails -d mysql myapp

처럼 하면 모든 작업을 예전처럼 할 수 있다고 한다.

꽤 많은 변화가 있는 것 같으니, 찬찬히 레일즈 2.x의 변화를 살펴봐야겠다.
"Web Development that doesn't hurt", "DRY(Don't Repeat Yourself)"라는 레일즈의 철학을 얼마나 잘 반영해 가고 있는지를 살펴보는 것도 레일즈 업데이트 변화를 바라보는 즐거움 중 하나다.

관련글 : Rails 2.0.2: Some new defaults and a few fixes
관련글 : Ruby on Rails 2.0.2 그리고 SQLite3

[Update]

모든 작업을 예전처럼 할 수 있다고 해서 그대로 하다 보니,
scaffold 메서드가 없다고 나온다.

undefined method 'scaffold'

dynamic scaffold 기능은 없어졌다는 얘기도 보이던데,
내가 잘못한 것인지 정말 없어진 것인지는 확인해 봐야겠다.
이유를 찾다 보니, scaffold 기능은 없어졌다고 한다.
(정확히는 Core에서 Plugin으로 이사했다고 해야 하나)

내가 처음 프로토타이핑용으로 레일즈를 선택했을 때 가장 큰 요인이 scaffold 였던 것을 생각하면 이 기능이 왜 빠졌는지 궁금해진다.

관련글 : Philosophy of scaffolding
관련글 : Is the rails 2.0 scaffold system philosophically ( not technically? ) broken?

관련 자료를 찾다 보니 Rails 2.0에 대한 유용해보이는 Tutorial이 있어 아래 링크한다.

읽을거리 : Rolling with Rails 2.0 - The First Full Tutorial - Part 1
읽을거리 : Rolling with Rails 2.0 - The First Full Tutorial - Part 2
읽을거리 : Rails 2 Upgrade Notes
읽을거리 : What's new in Rails 2?
읽을거리 : Rails 2.0 : It's done!