Rails(11)
-
[Ruby] Iconv 사용법
다음은 ruby에서 iconv을 사용하는 방법이다. # module 선언 require 'iconv' ... # EUC-KR을 UTF-8로 변환하기 위한 선언 conv = Iconv.new('UTF-8', 'EUC-KR') #Convert 'document' converted = conv.iconv(document) Tip1. Document내 확장 완성형 문자가 존재하는 경우, 에러발생 (참조 : superkdk in the NET) 위 참조에서 설명한 대로, "//IGNORE"옵션을 붙이면, 처리하지 못하는 문자열을 무시하도록 할 수 있다고 한다. # EUC-KR을 UTF-8로 변환하기 위한 선언 conv = Iconv.new('UTF-8//IGNORE', 'EUC-KR') Tip2. Ruby에서 R..
2007.11.12 -
RubyOnRails - Logger 기능
Rails App에는 3가지 구동 모드가 있다. [Development/ Production/ Test] Mongrel 웹서를 이용하는 경우, 다음 처럼 구동모드를 선택할 수가 있다. mongrel_rails start -e development -d -p mongrel_rails start -e production -d -p mongrel_rails start -e test -d -p 이 구동모드에 따라 각각 log파일이 따로 존재한다. /log/development.log /log/productiont.log /log/test.log Rails에서 제공되는 logging 이외 다른 log을 기록하고 싶다면 다음처럼 꾸리면 된다. ## Log 선언 표준 or 파일 입출력 모두 가능함 logger = L..
2007.11.01 -
[Rails] Ordered Hash
* ruby에서 hash을 쓰다보면, Hash table에 입력순서대로 값이 들어가질 않는다. 이 Ordered hash을 사용하게 되면, 입력 순서대로 값이 입력된다. Ordered Hash을 위해서, 몇가지 Gem을 설치하였다. GoodLibs - 현재 사용중인 것 (2006.05 이후로 업데이트 이루어지지 않음) Facets - Dictionary - 좀더 유명한 Gems, 하지만 "Sort" method을 지원하지 못한다. Sort method 을 지원하기 위하여, GoodLibs을 다시 설치하였는데, "File is not to unload" 라는 에러 발생한다. Gem 설치하고, Ruby Path가 잡혀있는데도 이런 상황. 혹시나 해서, GoodLibs 설치된 폴더에서 "ruby ordered..
2007.07.30 -
[Ubuntu] Mongrel 사용
# 가정 : Rails 설치 # Mongrel 설치 gem install gem-plugin mongrel mongrel_cluster --include-dependencies Select which gem to install for your platform (i486-linux) 1. mongrel 1.0.1 (mswin32) 2. mongrel 1.0.1 (ruby) 3. mongrel 1.0 (mswin32) 4. mongrel 1.0 (ruby) 5. Skip this gem 6. Cancel installation > 2 Select which gem to install for your platform (i486-linux) 1. fastthread 1.0 (ruby) 2. fastthread ..
2007.07.23 -
Ruby on Rails
Models / Views / Controllers 관계 Model- View- Controller Architecture - Model 모델은 Database와 연동하여, data 관리함 - View 뷰는 Model내의 Data을 이용하여, UI부분을 담당한다. - Controller 컨트롤러는 Model과 연동하여, 외부에서 Event들을 받아서 처리하고, 이를 사용자에게 적절한 View을 제공한다. Rails & MVC Instant Gratification Creating New Application > rails app (다음 폴더/ 파일들이 생성됨) > ruby script/server : 서버 동작 : http://localhost:3000 Hello Rails!! (ActionControl..
2007.07.10