Document for install ruby on rails on window and ubuntu

RUBY ON RAIL

Posted on 2014-11-24 04:19:31


Document for Ruby on rails 

 1) Ruby http://vi.wikipedia.org/wiki/Ruby

2. Rails Rails is framework which developed been for ruby programming language. http://guides.rubyonrails.org/getting_started.html 

 3. Setup ruby on rails & enviroment You should work with some jobs

1)	install apache & mysql ( use xampp )
2)	install ruby on rails – use railsinstaller.exe 
3)	Create and run the first project with rails(Default use rails with port 3000)
4)	Config project ruby on rails which use sqlite3 or mysql2 (for rails 3), or …
5)	Config  project ruby on rails which use apache server and run with port 80 for passenger.


I. Window system 

1)  Install apache & mysql Use xampp. You can download xampp at http://www.apachefriends.org/en/xampp-windows.html 

2) Install ruby on rails – Use railsinstaller.exe 

Download railsinstaller.exe 

 You can download at http://railsinstaller.org/ Package includes: Ruby,  devkit, rails

Then you install success, you can check

Open command line Ruby -v Check version of rails Rails -v

3) Create and run first project with rails

You can go to folder you want to create project. You can use command line cd /Users rails new project_name Folder project_name will be created at folder Users. You need cd to project then run rails server. cd project_name Then you can run command line: rails s Open browser and typing: localhost:3000 You can read more info at  http://guides.rubyonrails.org/getting_started.html

4) Config project ruby on rails use sqlite3 or mysql2 (for rails 3)

1. Using sqlite3 default when you create a new project with ruby on rails. Project will use sqlite3. 
2. Using mysql2 Config /config/database.yml
development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database:  my_database
  pool: 5
  username: username
  password: ‘password’
  socket: /tmp/mysql.sock
  host: localhost
Guide

http://www.railsviet.com/ket-noi-mysql-va-ruby-on-rails-tren-windows-dung-wampserver/

3. Use scaffold to create model, view, controller

$ rails generate scaffold Post name:string title:string content:text

II) Ubuntu system 

1. Install mysql server, apache 

2, phpmyadmin

 1.1 Install mysql server

Sudo apt-get install mysql-server

1.2 Install apache

Sudo apt-get install apache2

1.3 Install phpmyadmin

Sudo apt-get install phpmyadmin

2. Install rvm (ruby version manage) http://www.youtube.com/watch?v=j2vvXFGCtHM Check rvm

Type rvm | head -1
Rvm is a funtion

3. Install ruby with rvm

Rvm install version_ruby
Rvm use versin_ruby –defaults
Ruby -v

4. Install rails

Gem install rails

5. Install passenger (Link rails with apache) and config project's ruby on rails run on apache with port 80

Gem install passenger

http://www.kevinhq.com/2012/06/set-up-phusion-passenger-for-apache-in.html#.UMlC1eQz2gs http://articles.slicehost.com/2008/5/1/ubuntu-hardy-mod_rails-installation 

 Rails dir structure

  afb1d96119fdd4aee84bcc725e1f6f3c.media.461x541 

Structure of rails framework include sub dir controllers, models, views, helpers...

2)	Configuration
   This folder include all file configs of system example: routes, databases, application.
3)	Db
   This folder include file the first scripts for build database
4)	Doc
   Comment for code. 	
5)	Lib
   All libraries include to project
6)	Log
   File logs of project.
7)	Public
   Include javascript, css, images.
8)	Vendor
   All libraries link from foreign system which is not supply by rails, it is supplied from Third-party provider
9)	Tmp
   All file temps of system
 
You can see more info from here
http://dev.vast.vn/tuananh/Web/C%C4%90048-3 http://www.tutorialspoint.com/ruby-on-rails/rails-directory-structure.htm
And more ruby on rails