You are currently browsing the archives for the ruby category.

Posted on November 21, 2007 at 10:20 pm

Leopard, ImageMagick gem

I was searching the internet looking for a way to install the ImageMagick gem on Leopard, and lone behold i found it!

YAY

http://nullstyle.com/2007/10/27/how-to-build-imagemagick-and-install-rmagick-with-macports-on-mac-os-x-leopard/

Posted on March 23, 2007 at 11:36 am

BUG: Found and solution

There seems to be a bug in the latest versions of Ruby on Rails that is installed on the cias web server
If you are seeing in your ruby logs:

ActionController::RoutingError (no route found to match

and from the web you are seeing:
no route found to match "/blah" with {:method=>:get}

Then you need to do the following

edit your config/boot.rb line that reads
root_path = Pathname.new(root_path).cleanpath(true).to_s
to
root_path = Pathname.new(root_path).cleanpath(true).realpath().to_s

Run: sudo cias_killruby
This script is a new feature i’ve made that will kill your ruby processes on the server

The actual bug report is at: http://dev.rubyonrails.org/ticket/6755

I hope this helps everyone

Posted on February 18, 2007 at 10:10 pm

Creating a Rails Application on cias.rit.edu

**disclaimer**
I would like to thank Adam Miller very much for working with me to create an environment that can run ruby on rails, and for providing this great how-to for creating rails application on cias.rit.edu I personally cannot take any responsibility for the great work he's done documenting these steps. Bravo Adam.

Prerequisite:

You should be comfortable typing in commands to a command line interface. You should also be sure to have rails, mysql, and a server running on your local machine for development. Your rails app will run in production mode on the CIAS server, so you will not be able to access many of the debugging tools that development mode offers you.

That sound good? Alright, here we go!

Step 1: Creating the Apps Directory

For reasons of security and flexibillity, I'm going to recommend creating a directory for your applications to live in. We don't want to have your apps live in a public facing directory so lets create it as low as we can go (your home folder).

CODE:
  1. cd ~
  2. mkdir apps
  3. cd apps

Step 2: Setting up your app

We're already to go now just call the rails command to build your new application:

CODE:
  1. rails your-apps-dir

This will create a brand new rails app for you. If you already have been developing your application locally, you can also deploy your application here. Hopefully your using subversion to manage your files and you can just checkout a version of your app:

CODE:
  1. svn co path-to-repository app-name

If not you could use ftp to get your local files up on the server, although I would not recommend this method at all.

Step 3: Set permissions

By default, the permissions will be set incorrectly, and we can't have that.

CODE:
  1. cd ~/apps/your-apps-dir/public 
  2. chmod 755 *

I've also found that if your generating a new rails app, your tmp directory and its contents will have incorrect permissions as well.

CODE:
  1. chmod 777 tmp/* tmp

Step 4: Create the symbolic link

Create a symbolic link to your apps public directory. For this tutorial, I'm assuming you will want to run your application from the apps directory we set up in step 1.

CODE:
  1. ln -s ~/apps/your-apps-dir/public/ ~/public_html/app-shortcut-name

If you want your application to run at your root level, then replace your public_html folder with your symbolic link.

CODE:
  1. mv ~/public_html ~/public_html_backup
  2. ln -s ~/apps/your-apps-dir/public/ ~/public_html/

Step 5: Edit your .htaccess file.

In your apps public directory, edit the .htaccess file using your favorite editor. Because your app is not going to be running at the root level (if it is, you may be able to just skip this step), you'll need to tell the server how it should map your urls. Above the very first RewriteRule add this line.

CODE:
  1. RewriteBase /~your-account/symbolic-link-name/

Again, if your running your app in your public root, just leave off the symbolic-link-name.

We also need to make sure apache knows we want to use fastcgi to run our application. Add this line to the top of your .htaccess file:

CODE:
  1. AddHandler fcgid-script .fcgi

Then we also need to rewrite this line:

CODE:
  1. RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

to be:

CODE:
  1. RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

So that we make sure we're using fastcgi insead of just cgi. Your app will be painfully slow (and consume a lot of resources) if your not running with fastcgi.

Now you should be able to visit
http://cias.rit.edu/~your-account/symbolic-link-name/
And you should see the rails welcome message. If your deploying an application that you have already started, you may see an error instead of the rails welcome message. Don't worry about this as we have not finished setting up the database yet. Onward ho!

Step 6: Database hookups

You'll need to edit the production database values in database.yml. Each cias account (as far as I know) comes with a mysql database in the name of your account. So we can edit it to look something like this:

CODE:
  1. production:
  2. adapter: mysql 
  3. database: your-account-name
  4. username: your-account-name
  5. password: your-accounts-password
  6. host: cias.rit.edu

Step 7: Production mode

As of this writing, cias.rit.edu is not set up to force your app into production mode by default. It's important to run production mode because it is more secure and consumes less resources. In the app of your rails directory, open up config/enviornment.rb and add this line somewhere towards the top:

CODE:
  1. ENV['RAILS_ENV'] ||= 'production'

Step 8: Enjoy!

And that should do it! Your app should be up and running. If you have problems feel free to shoot me an email: acm6603[at]gmail.com. Google is also very helpful even though it won't be specific to this server.

Posted on January 10, 2007 at 2:40 pm

Ruby on Rails

Well, students have asked for it, so I made it happen! The CIAS webserver now supports Ruby on Rails in your own user directory. I am going to be honest and say I don't know much about on Ruby on Rails, so i'm willing to work with any student at making the configurationg of the server to work great for all you students!