Even more Quick Reference fun!

I’ve posted yet another quick reference guide, this time for Prototype, the javascript framework that Ruby on Rails uses. Sure, you are probably going to use the RJS helpers for just about everything, but it’s very helpful to understand the underlying syntax as well.

On to the Prototype Quick Reference guide.

Ruby on Rails: script/console reload!

Somebody just showed me this on the #rubyonrails channel over on freenode… when you make changes to your model objects, you can reload the changes inside the script/console by just doing this:

?> ?> reload! Reloading... => [Article, User, ApplicationController] >>

Rather useful, I’d say. You can also load up ruby code in an external file by using the “load” command.

Ruby on Rails: Beautiful Charts Made Easy – using Flash with Rails RXML templates

I’m in the process of developing an application in Ruby on Rails, the main purpose of which is to collect information and output reports. One of the main requirements I was given was that we needed “cool looking reports with charts and stuff”. My job has been reduced to making stuff. Sigh. Moving on…

Having some past experience with reporting and charting, I immediately started cringing at the thought of the overload generating some of these reports place on the server. Creating a chart requires writing out images and either caching them or directly streaming them out to the browser…. which can place an undue strain on the server. To further complicate things, this application is going to be hosted by a regular provider, so I have to make sure that whatever provider I choose supports the image generation library I pick. Now I’m sad again.

Enter Flash Charts.

(Continued)

Ruby on Rails: Using Full Text Search with Tagging

I’m working on a new application in Rails that uses both Tagging as well as full text indexing. I decided to go with Ferret, which is just a Ruby port of Lucene. Using the acts_as_ferret plugin, it’s dead simple to integrate into your application. First, you want to install Ferret on your machine, and then run this command:

script/plugin install svn://projects.jkraemer.net/acts_as_ferret /tags/stable/acts_as_ferret

At this point, you are ready to start enabling searching on your objects. Let’s say you want to enable full text search through a list of blog posts in your application. All you need is to add the acts_as_ferret line to your model class.

(Continued)

Ruby on Rails Quick Reference

I’m constantly trying to remember the syntax of commonly used commands, or which command to use for what I’m trying to accomplish. Just today I was trying to figure out the syntax for using rake db:migrate to migrate Backwards. ( it’s rake db:migrate VERSION=x ) I figured I’d put together a list and post it up here, in the off chance it’ll help somebody else…

Instead of making it a blog post, I figured it would be better to make it a static page, so I’ve made my first WordPress “page” ever…   One of the annoying things about using the WordPress “page” feature is that you are forced to use the admin panel, which I detest… there’s also no support for tables, whether in WordPress admin or Windows Live Writer. Are tables completely banned from blogs?

So, you can find the Ruby on Rails Quick Reference over on the left hand menu. I’ll be updating it over time to include more things, especially as I continue to learn more about Rails.