검색결과 리스트
IT(Old)/RubyOnRails-Tip에 해당되는 글 14건
- 2008.01.21 시간/날짜 관련 표현식
- 2008.01.21 테이블 명명규칙
- 2008.01.21 my sql DB config(database.yml)
- 2008.01.21 ruby 서버 포트 변경
글
시간/날짜 관련 표현식
t = Time.now
t.strftime("%Y/%m/%d %H:%M:%S")
=>2008/01/21 12:13:30
t.strftime("%y/%m/%d %I:%M:%S %p");
=>08/01/21 12:13:30 PM
초를 더할때
t2 = t + 30
5일을 더할때
t3 = t + 60*60*24*5
크기로 비교 가능
t2 < t3
today = Data.today
christmas = Date.new(2007,12,25)
날짜는 +연산을 하면 일자가 더해진다.
설정
트랙백
댓글
글
테이블 명명규칙
rails에서는
테이블명에는 복수형을(끝에 s붙임)
모델은 단수형을 사용한다.
그래야...자동으로 테이블 일대일매핑이 가능하다.
ㅡ.ㅡ
설정
트랙백
댓글
글
my sql DB config(database.yml)
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: mysql
database: test
username: root
password: xxxxx
encoding: utf8
# 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: test
username: root
password: xxxxx
encoding: utf8
production:
adapter: mysql
database: test
username: root
password: xxxxx
encoding: utf8