Category Archives: Ruby on Rails

Ruby on Rails related content

Rails 3 on WHM / cPanel VPS Server

cPanel is working towards making Rails 3 applications run natively with Passenger, setup via the cPanel interface. I’m not really sure if this will be ideal, as most organizations deploy their apps to the server using Capistrano, not uploading via FTP or something. I’ve been hosting a number of PHP driven sites, including this blog,…

Configuring Rails 3.1.3 under Sub-URI

In setting up a new Rails app recently I was told that it needed to be served under the sub-URI of ‘/info’. I hadn’t done this before with a Rails app, and I expected that it could be tricky. I checked online to see how this is done and found references to the ‘relative_url_root’ setting,…

Custom Rake Tasks Not Loading

I recently went to create a new Rake task under /lib/tasks in a Rails application I’m working on. I didn’t understand why the rake tasks weren’t showing when I would run ‘rake -T’ from the command line. When I’d try to run the task itself I would get a ‘Don’t know how to build task’…

Troubleshooting ActiveResource Requests

I’m currently working on an app which integrates with the HighRise API using the Highrise Ruby wrapper gem. The classes defined by the gem rely on ActiveResource, the Ruby library included with Rails for interfacing with RESTful resources like the HighRise API. Sometimes I’m not sure if the requests being made via the commands I’m…

Example Rake Task

Here is example rake task code which you can use and modify the next time you’re setting up new Rake tasks for a Rails app from scratch. The example includes the syntax for setting the default task, running multiple tasks in order, and a task which includes multiple arguments. This coding syntax works with Rails…

Resolving issues with Namespaced Models in Rails 3.1.0

I recently was tasked with upgrading an application from Rails 2.3.8 to Rails 3. I choose to upgrade it to Rails 3.1, because why upgrade once and then have to do it again later. After upgrading and testing many points of the system locally, I was ready to push the upgraded application to the production…

Paperclip error with non-image file

Recently I updated to Rails 3.1 from 2.3.8 for a project I’m working on. Paperclip version 2.4.5 was working perfectly well for me locally on my Mac OS X 10.7.2 laptop, with ImageMagick version 6.7.3-1. We had just launched the upgraded Rails 3.1 application to our production server, which went smoothly, but upon my checklist of…

Issues with RVM

I recently decided to check out BrowserCMS, to evaluate how it work and decide to use it…or RefineryCMS. I didn’t expect that BrowserCMS would require Ruby 1.9.2. I’ve been running with Ruby 1.8.6 or 1.8.7 for quite a while now without any issues. It looks like it was time that I install RVM: Ruby Version Manager….

Redirect_to not working

I was just working on a Ruby on Rails controller method that receives information from the previous form via HTTP POST. I coded it so that if certain form variables weren’t present it would set a flash message and redirect to the form page. I tried and tried and still the redirect wasn’t working. I…

Advanced Use of Will_Paginate

I’m building an index of contacts, displayed with paginated links provided by will_paginate. The wiki for this plugin advises you on how to do setup your controller method, and what to put in the view to obtain a simple set of links, such as: # /app/controllers/contact_controller.rb def index @contacts = Contact.paginate :page => params[:page], :per_page…