RubyOnRails
Ruby on Rails 1.2 on the SME Server 7
Web development that doesn't hurt http://rubyonrails.org/
Ruby on Rails is an open-source web framework that's optimized for programmer happiness and sustainable productivity. It lets you write beautiful code by favouring over configuration.
Here is how to get it up and running on your SME Server. You need to be root (su -) to do the following actions.
Add CentOS – testing Repository
The base CentOS repositories have an outdated ruby version, so we need to get it from the CentOS testing repository. Setup the centos-testing repository as per below:
db yum_repositories set centos-testing repository \ BaseURL http://dev.centos.org/centos/4.3/testing/i386/ \ Name 'CentOS - testing' \ Visible yes \ GPGKey http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing \ GPGCheck yes \ status disabled
Regenerate the yum.conf file:
expand-template /etc/yum.conf
Install Ruby
Then use yum to install ruby and associated packages:
yum --enablerepo=centos-testing install ruby ruby-libs ruby-devel \ ruby-mysql ruby-ri ruby-postgres ruby-rdoc ruby-docs
Check that ruby is properly installed with:
# ruby -v ruby 1.8.5 (2006-08-25) [i386-linux]
Install RubyGems
RubyGems http://rubygems.org/ is the ruby packaging system. wget the latest version from the RubyForge repository (http://rubyforge.org/frs/?group_id=126). Unpack the tar file and install the package as per below:
wget -c http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz tar xzvf rubygems-0.9.2.tgz cd rubygems-0.9.2 ruby setup.rb cd ..
Install Rails
With the gem package manager installed, you are now one step away from installing Rails
gem install rails –-include-dependencies
Creating a New Rails Application
To create a Rails application, open a shell and navigate to a place in your file system where you want to create your application.
> mkdir work > cd work work> rails demo create create app/controllers create app/helpers create app/models : : : create log/development.log create log/test.log
Change to the directory in which your application was created:
work> cd demo demo> ls -p app/ config/ doc/ log/ Rakefile script/ tmp/ components/ db/ lib/ public/ README test/ vendor/
Start the embedded webserver:
demo> ruby script/server => Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with development environment... ** Rails loaded. ** Loading any Rails specific GemPlugins ** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart). ** Rails signals registered. HUP => reload (without restart). It might not work well. ** Mongrel available at 0.0.0.0:3000 ** Use CTRL-C to stop.
And open up your browser to http://your_server_url:3000 and admire the welcome page of your new Rails application!
References
RubyOnRails http://rubyonrails.org/
RubyGems package manager http://rubygems.org/
Extending Rails with plugins http://wiki.rubyonrails.org/rails/pages/Plugins
Recommended Editors
TextMate http://macromates.com/ (MAC OS X)
RadRails http://www.radrails.org/ (Eclipse IDE)