'Web Tech./Ruby on Rails'에 해당되는 글 3건

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

Cloud9 Ruby, DB 변경 하기 (sqlite3 -> mysql )



1. 기본 Template선택


2. MySQL 설치하기



3. Config변경하기

- 복사본 만들기 : cp config/database.yml config/database.yml.sqlite3

- Gemfile추가하기 : gem 'mysql2' 

- bundle 설치 : bundle install

- config/database.yml 변경하기

4. Database생성하기

> mysql-ctl cli

> create database scaffold2_development;

> create database scaffold2_test;


5. Table 생성하기

- bash 쉘 열기

>rake db:migrate



6. rake db:migrate 오류 발생시 


- Rails Specified 'mysql2' for database adapter, but the gem is not loaded.


https://medium.com/sudogem/rails-specified-mysql2-for-database-adapter-but-the-gem-is-not-loaded-add-gem-mysql2-to-your-gemfile-d35bb40eb961


#gem 'rails', '4.2.5'

#gem 'mysql2', '~> 0.3.20'


* Scaffold 프로젝트 생성하기


>rails g scaffold post title:string content:string

>rake db:migrate


# Run Project

# Preview


'Web Tech. > Ruby on Rails' 카테고리의 다른 글

Cloud9 Ruby Rails의 MySQL설정  (0) 2018.10.11
Ruby on Rails 설치하기 ( VMware + Ubuntu )  (0) 2018.04.17
블로그 이미지

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.

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


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.

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



OS 설치하기 ( VMware + Ubuntu )



# VMware 설치 : VMware Workstation 12 Player 다운로드 & 설치


# Ubuntu ISO 다운로드 : www.ubuntu.com , Download -> Desktop




참조 : http://recipes4dev.tistory.com/111




Ruby on Rails ( ROR ) 설치 하기 with RVM



# gpg command contact a public key server and request a key


> gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB



# curl command download the RVM installation script

> cd /tmp

> curl -sSL https://get.rvm.io -o rvm.sh

> cat /tmp/rvm.sh | bash -s stable --rails


- Add $PATH : ~/.rvm/scripts/rvm 또는 ./ 


# install specific ruby and rails versions

>rvm install 2.4.1

>rvm use 2.4.1 

>gem install rails -v 4.2.7


>rvm list known

>rvm list

>gem search '^rails$' --all 


# install java script runtime (node.js)





참조 : https://www.digitalocean.com/community/tags/ruby-on-rails?type=tutorials



'Web Tech. > Ruby on Rails' 카테고리의 다른 글

Cloud9 Ruby DB 변경 하기 (sqlite3 -> mysql )  (0) 2018.10.16
Cloud9 Ruby Rails의 MySQL설정  (0) 2018.10.11
블로그 이미지

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.

,