Following in the footsteps of CakePHP there is Ruby on Rails which is also a MVC framework. It is based on the Model, View, Controller (MVC) philosophy:
It is preferable if you can get by to install Ruby with out having
to resort to the Ruby Virtual Manager. With the RVM other applications
can be confused by the path. You may have to do quite a bit of work
to get the paths straight. After much experimentation, I found a
winning combination of downloading the following Ruby and Rubygems code
from source and compiling. Here is what I did:
To install Ruby on Rails get all the usual LAMP modules, i.e.:
apt-get install apache2 php5 mysql-client mysql-server php5-mysql
Restart Apache2 to be safe with the command:
Riding the Rails these days is a lot more complex than it used to be. After messing around for a day to update my page from 2009 I was getting into some huge stumbling blocks such as:
mysql2 module missing
no such file to load -- openssl
This happened when doing the intial rvm install 1.9.2
That is the initial ruby install or
gem install rails
which runs automatically when you are creating a new Rails app with:
rails new blog -d mysql
Note, the previous is run in the /home/victor/myapp directory which is my default for Rails applications. Thankfully there is a way out of this conundrum here My hats are off to Mircea Goia who deserves a thousand thankyous!!! Note, I have just given you a link so you can get it directly from Mircea. I will try and keep the copy on my site current with his as he updates it. Bravisimo! Following is what worked for me on my little Asus eeePC. Please read his brillant document first which I am providing.
Now, that you have read the 40 page document, you will see that the key here is using the Ruby Version Manager. This way you can keep all your Rubies and Rails straight and change them on the fly. You can do this because you installed Git that I mentioned in my Drupal Webpage (at the bottom), which does configuration control management of programming code. It is the next thing after subversion created by the great Linus Torvalds who invented Linux!
This is a brief summary of what I did:
sudo apt-get install build-essential git-core curl
Get the git modules in there for now.
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
This will get the Ruby Virtual Manager in there for compiling from Souce various version of Ruby. We are going for the 1.92 here for Ruby and the 3.1 for Rails.
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
Now see if you can execute the home .bashrc script. I could not so I had to make it executable with:
ls -al .bashrc
chmod 744 .bashrc
Now put in all the other goodies. Note, this is from the Ubuntu repositories.
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev
Note, you do not install zlib with sudo because it does not exist in the repos for 11.10.
sudo apt-get install libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev
sudo apt-get install libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison
rvm install 1.9.2
Install the sucker. If it's successfull type:
and you should get a version number back of 1.9.2. If not successfull follow the master's doc I mentioned in the first paragraph of this web page.
rvm --default use 1.9.2
This will force Ruby Virtual Manger to use this version for all terminals. You can change it any time with:
rvm use x.y.z
where x.y.z are the new version numbers you are testing. Now install rails without sudo because you are using the Ruby package manager gem
gem install rails
should give you 3.1.0 for me. pwd
to verify you are where you want to be, i.e. home/victor/
and you should see a directory myapp, if not there create it. cd myapp
rails new blog -d mysql
to create my new Rails application blog. Now I need to edit the database appropriately to put in passwords in this file:
to create a database. I got an error that was mentioned at the very top of this page about a missing execjs module in the Gemfile so I did:
I added in the two lines below:
You can add it in anywhere, but I tried to do it in alphabetical order. Then at the blog
Lastly, update the gem with
sudo gem update --system
You are now through the hardest part, take a break.
For testing keep the Webrick server, but later you may want to install the Phusion Passenger so you can ride in style on the Rails with your production server. It is all in the doc, just hop on board!
It is real important to verify that you have everything running doing the Webrick test, that
is go to a terminal prompt and type the following:
Note, I created the blog Ruby test application using the Linux tutorial mentioned at the end of this page. In the directory type:
to launch the Webrick server.(Yeah, it is a brick, we will not use it for production, relax!) Then when you go to:
http://localhost:3000 in your web browser and click on the about your applications environment you shoud see all of this:
Ruby version 1.9.2 (i686-linux)
RubyGems version 1.8.10
Rack version 1.3
Rails version 3.1.3
Active Record version 3.1.3
Action Pack version 3.1.3
Active Resource version 3.1.3
Action Mailer version 3.1.3
Active Support version 3.1.3
There is a gap of stuff I am leaving out *******
Application root /home/victor/myapp/blog
Database adapter mysql2
Database schema version 0
If you do not see all this, check the load order for any web servers that you have, i.e.:
rails server from your /home/victor/myapp/blog directory
I found that if I reversed the load order of the above, I would get an error. It is darn finicky, if you ask me. This is the hardest part of the entire Ruby project. You can waste days, thinking something is wrong when it is just the server order load.
This was a little bit tricky after doing
You can follow the document from Mircea Goia , I mentioned earlier. I had to do these additional things to get it working for me.
A lot has changed between Rails 2 and Rails 3, therefore I recommend this
highly. Among the stuff to take notice of is the routes.rb syntax is completely different
from what it was before. This should be enough to get you well on your way. Note, it is
written for the MS Windows folks, but is almost identical in Linux on Ubuntu for me.
Instead of "bundle exec rake db:migrate" you would use:
Also note if you try to run the rails console in the script directory you may get the error about readline module missing . This is solved by the following:
sudo apt-get install libreadline-gplv2-dev lib64readline-gplv2-dev
Change directories to the ruby rvm source directory for your particular version:
This should return you to the ..script directory where you can again run:
So what is all this good for? There are a lot of applications out there that
use the Ruby Platform. One of them is Chef from Opscode Inc. Here
Fast Start Guide for installing it. Note, I had
to install both the Ruby and the Ruybgems from source,
as described in the very first section of this web page.
To verify that Ruby is running properly
you not only want a version number, but you should be able to
find a rbconfig.rb file . i.e. :
You must recompile your source if you do not have this file. Also for the Chef application do not use RVM (Ruby Virtual Manager) otherwise this config file will not be found.
You can now follow along in the Fast Start guide copying the generated keys to
get the chef-client installed. I ran into an error saying that
Config has been deprecated, use RbConfig instead
when doing the final command with
Therefore I edited the ohai/plugins/os.rb files replacing the appropriate line as in below:
sudo vi /usr/local/lib/ruby/gems/1.9.1/gems/ohai-0.6.10/lib/ohai/plugins/os.rb
#This is the replaced line
# Victor changed previous line RbConfig is now used instead of Config
After doing this rerun the "sudo chef-client" command and do the same for any more files you may find. For me this was in :
Now everything should work when you do a
[Sun, 15 Jan 2012 16:54:14 -0800] INFO: *** Chef 0.10.8 ***
[Sun, 15 Jan 2012 16:54:18 -0800] INFO: Run List is 
[Sun, 15 Jan 2012 16:54:18 -0800] INFO: Run List expands to 
[Sun, 15 Jan 2012 16:54:18 -0800] INFO: Starting Chef Run for victor-900HA
[Sun, 15 Jan 2012 16:54:18 -0800] INFO: Running start handlers
[Sun, 15 Jan 2012 16:54:18 -0800] INFO: Start handlers complete.
[Sun, 15 Jan 2012 16:54:19 -0800] INFO: Loading cookbooks 
[Sun, 15 Jan 2012 16:54:19 -0800] WARN: Node victor-900HA has an empty run list.
[Sun, 15 Jan 2012 16:54:25 -0800] INFO: Chef Run complete in 7.116631734 seconds
[Sun, 15 Jan 2012 16:54:25 -0800] INFO: Running report handlers
[Sun, 15 Jan 2012 16:54:25 -0800] INFO: Report handlers complete
victor@victor-900HA:~/chef-repo$ knife client list
Now you can move on to working with Cookbooks if you choose.