Adding Ruby on Rails to the development environment
Ruby on Rails
Once you have your basic development environment up and running, you may want to add Ruby on Rails to it. Follow these steps.
Tools to install
$ sudo yum install ruby$ sudo yum install ruby-devel
$ sudo yum install sqlite-devel
$ sudo gem install rails
$ sudo gem install therubyracer
Install MySQL
This page is far more informative and covers many other use cases and linux variants: http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch34_:_Basic_MySQL_Configuration
But, if you want a super-quick startup, here goes...
$ sudo yum install mysql
$ sudo yum install mysql-server
$ sudo yum install mysql-devel
$ sudo chkconfig mysqld on
$ sudo service mysqld start # or reboot
$ mysqladmin -u root password "the password"
$ mysql --user=root --password="the password"
mysql> create database dev;
mysql> grant all privileges on dev.* to devuser@"localhost" identified by 'a password';
Pro Tip: If you are in a VM this would be a great time to take a snapshot.
$ mkdir test
$ cd test
$ rails new testapp
$ cd testapp
$ vi Gemfile
<add the line, "gem 'therubyracer'" somewhere near the top of the file>
$ rails server
Start a web browser and navigate to: http://localhost:3000/ You should see the test app page.
$ mkdir test
$ cd test
$ rails new testdb -d mysql
$ cd testdb
$ vi Gemfile
<add the line, "gem 'therubyracer'" somewhere near the top of the file>
$ vi config/database.yml
<find the "development" section and change your user, password, and database name>
$ rails server
Start a web browser and navigate to: http://localhost:3000/ You should see the test app page.
$ mkdir test
$ cd test
$ rails new testdb -d mysql
$ cd testdb
$ vi Gemfile
<add the line, "gem 'therubyracer'" somewhere near the top of the file>
$ vi config/database.yml
<find the "development" section and change your user, password, and database name>
$ vi config/routes.rb
<add the line, " resources :users">
# Read more about routes here: http://guides.rubyonrails.org/routing.html
$ rails generate conroller users
$ rails generate model users
$ vi app/views/users/index.html.erb
<Put a "hello world" page in it>
$ rails server
Start a web browser and navigate to: http://localhost:3000/users You should see the "hello world" page.
But, if you want a super-quick startup, here goes...
$ sudo yum install mysql
$ sudo yum install mysql-server
$ sudo yum install mysql-devel
$ sudo chkconfig mysqld on
$ sudo service mysqld start # or reboot
$ mysqladmin -u root password "the password"
$ mysql --user=root --password="the password"
mysql> create database dev;
mysql> grant all privileges on dev.* to devuser@"localhost" identified by 'a password';
mysql> quit;
$ mysql --user=devuser --password="a password"
mysql> use dev;
mysql> use dev;
Verify Rails is Working
$ cd ~$ mkdir test
$ cd test
$ rails new testapp
$ cd testapp
$ vi Gemfile
<add the line, "gem 'therubyracer'" somewhere near the top of the file>
$ rails server
Start a web browser and navigate to: http://localhost:3000/ You should see the test app page.
Verify Rails can communicate with MySQL
$ cd ~$ mkdir test
$ cd test
$ rails new testdb -d mysql
$ cd testdb
$ vi Gemfile
<add the line, "gem 'therubyracer'" somewhere near the top of the file>
$ vi config/database.yml
<find the "development" section and change your user, password, and database name>
$ rails server
Start a web browser and navigate to: http://localhost:3000/ You should see the test app page.
Create a Rails "Hello World" app
$ cd ~$ mkdir test
$ cd test
$ rails new testdb -d mysql
$ cd testdb
$ vi Gemfile
<add the line, "gem 'therubyracer'" somewhere near the top of the file>
$ vi config/database.yml
<find the "development" section and change your user, password, and database name>
$ vi config/routes.rb
<add the line, " resources :users">
# Read more about routes here: http://guides.rubyonrails.org/routing.html
$ rails generate conroller users
$ rails generate model users
$ vi app/views/users/index.html.erb
<Put a "hello world" page in it>
$ rails server
Start a web browser and navigate to: http://localhost:3000/users You should see the "hello world" page.