노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Cloud9 Ruby Rails의 MySQL설정


1. c9 가입후 workspace생성


- Ruby template은 sqlite3로 설정되어서, Blank template를 선택

- Workspace Name은 'ror'로 임의 부여



2. Terminal에서 MySQL 사용 설정

- mysql-ctl install 실행


mysql-ctl cli를 통해 mysql console 접속(show databases등 명령어 실행)


3. Rails 설치 

: gem install rails


4. Ruby on Rails MySQL 프로젝트 생성

 : rails new scaffold1 -d mysql



5. Database 생성하기

 : mysql-ctl cli로 console접속


- create database scaffold1_development

- create database scaffold1_test



6. config/database.yml 수정 (필요한 부분)


- username : <%= ENV['C9_USER'] %>

- database :

- host : 


7. 서버 실행 

- rails -s -b $IP -p $PORT


8. 접속 주소 확인 

: 메뉴상의 Preview를 통해서 확인

 

9. MVC패턴으로 만들기

Controller생성>rails g controller home
Action 만들기

: 요청을 받고 이를 처리하는 최소 단위
app/controllers/home_controller.rb

def index
end
Action에 대응하는 View 생성하기
app/view/home/index.html.erb

<h1>Hello, World</h1>
Layout (기본 제공)
app/views/layout/application.html.erb

<%= yield %>
Route 명시하기

: 특정 경로를 Controller의 Action에 매칭
HttpType(get,post) 'path'=>'Controller#action'
config/routes.rb

get '/'=>'home#index'



블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,