Generator 설치하기

  • Post author:
  • Post category:
  • Post comments:0 Comments
  • Post last modified:February 7, 2020

Ruby on Rails에는 model, controller등 10여 개의 generator가 기본 탑재되어 있다. 물론 이외의 Generator를 스스로 만들거나 다운로드 받아서 사용할 수도 있다. LoginGenerator를 설치했다고 생각해보자. LoginGenerator 문서는 다음과 같이 설명하고 있다.

gem install login_generator

Once installed, consult the usage page via

script/generate login

오, 쉽네! 차분히 따라해보자. 안타깝게도 두 번째 명령어는 작동하지 않는다. Couldn’t find ‘login’ generator이라는 오류 메시지가 뜰 것이다. 이같은 현상이 벌어지는 이유는 중요한 단계 하나가 빠졌기 때문이다. C:\ruby\lib\ruby\gems\1.8\gems\login_generator-1.2.2에서 찾을 수 있다. 물론 1.8이나 1.2.2 같은 버전 값은 상황에 따라 다를 것이다.

윈도우

우선 gem으로 내려받은 LoginGenerator를 찾는다.

login_generator-1.2.2 폴더를 통째로 다음 경로에 복사한다. 사용자 계정이 Alice이고 LoginGenerator를 설치하는 경우라면, C:\Documents and Settings\Alice\.rails\generators\login가 된다.

C:\Documents and Settings\[username]\.rails\generators\[generator_name]
	USAGE
	[generator_name]_generator.rb
	/templates
		[any tempalte files, named appropriately]

여기서 잠깐! .rails와 같이 점으로 시작하는 폴더를 생성하려고 하면 오류 메시지가 뜬다. 문제는 쉽게 해결할 수 있는데, 단순히 명령 프롬프트로 들어가서 mkdir .rails라는 명령을 치면 된다.

Rails Tip! Generator 설치하기 - mkdir

유닉스/리눅스

Understanding Generators는 다음과 같이 기술하고 있다. 직접해 본 적이 없어서 자세한 설명을 하지 않는다.

~/.rails/generators/[generator_name]
	USAGE
	[generator_name]_generator.rb
	/templates
		[any template files, named appropriately]
Author Details
Kubernetes, DevSecOps, AWS, 클라우드 보안, 클라우드 비용관리, SaaS 의 활용과 내재화 등 소프트웨어 개발 전반에 도움이 필요하다면 도움을 요청하세요. 지인이라면 가볍게 도와드리겠습니다. 전문적인 도움이 필요하다면 저의 현업에 방해가 되지 않는 선에서 협의가능합니다.
0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments