No Reservations about Keywords in Ruby on Rails

Posted by Daniel Butler Wed, 31 Jan 2007 21:05:00 GMT

Thesaurus

Have you ever had the urge to name a data model in your Ruby on Rails application something obvious, like Action, Table, File, Columns, or Database? Well, don’t. Choosing a name like that might work for you in some cases, but it might fail miserably for someone else using a different database engine (i.e., MySQL verses PostgreSQL verses Oracle).

Think you can remember all the problematic names? Think again. There are at least 974 known keywords which can give you problems. I started with the ReservedWords pages on the Ruby on Rails Wiki, and pulled in and merged all the SQL-92, SQL-99, SQL-2003, PostgreSQL, MySQL, SQL Server and ODBC reserved keywords, and put them in one place, mainly for my own future reference.

So what if your data models are about Databases, Tables, Columns, and Files? Simply think of a Good Prefix™, and name all your models accordingly: DaDatabase, DaTable, DaColumn, and DaFile, with resulting table named da_databases, da_tables, da_columns, and da_files. It’s easy, painless, and helps you group similarly-purposed tables and models accordingly, and you don’t have to wrack your brains thinking of synonyms for obvious model names like “Action”. I use Geo- for location-oriented data, Sys- for System-oriented tables, Log- for transactions, and App- for application-oriented tables.

Read on to see the full list …

Read more...

Posted in  | 2 comments

Better Subversion External Branch Management with Piston

Posted by Daniel Butler Thu, 02 Nov 2006 01:59:00 GMT

Subversion exports can be difficult to manage in your Ruby on Rails application, especially if you want to make local changes to a vendor-supplied plugin that shouldn’t really be applied back to that vendor’s trunk (or cannot be). Another reason to keep the vendor’s code checked into your own tree, is that you’ll be able to better see changes to the vendor’s code as they happen and assess the impact on your own code, as well as audit vendor changes that break your application in some way. Externals cannot provide such a safety net. So, into the cylinder of Rails plugins enters Piston by François Beausoleil of Sherbrooke, Québec, Canada. His description:

Piston is a utility that eases vendor branch management. This is similar to svn:externals, except you have a local copy of the files, which you can modify at will. As long as the changes are mergeable, you should have no problems.

Watch him demonstrate its usage:

$ piston import http://dev.rubyonrails.org/svn/rails/trunk vendor/rails
Exported r4720 from 'http://dev.rubyonrails.org/svn/rails/trunk' to 'vendor/rails'
$ svn commit -m "Importing local copy of Rails"
$ piston update vendor/rails
Updated 'vendor/rails' to r4720.
$ svn commit -m "Updates vendor/rails to the latest revision"

As a bonus feature, you can lock piston-gripped trees with piston lock to prevent subversion from updating past a specific vendor’s revision that works with your application. Nice work, François.

Piston @ RubyForge

Posted in  | no comments

Rails Plugins Made Even Easier with RaPT

Posted by Daniel Butler Fri, 27 Oct 2006 15:08:00 GMT

Wow, can discovering and installing helpful Rails plugins get any simpler than this?

$ gem install rapt
Successfully installed rapt-0.2.1
$ rapt search "full text search"
Active Search
  Info: http://www.agilewebdevelopment.com/plugins/show/22
  Install: http://julik.textdriven.com/svn/tools/rails_plugins/simple_search
Indexed search engine
  Info: http://www.agilewebdevelopment.com/plugins/show/63
  Install: http://langwell-ball.com/svn/indexed-search/trunk/indexed_search_engine/
Acts as Ferret
  Info: http://www.agilewebdevelopment.com/plugins/show/83
  Install: svn://projects.jkraemer.net/acts_as_ferret/trunk/plugin/acts_as_ferret
Searchable
  Info: http://www.agilewebdevelopment.com/plugins/show/236
  Install: http://svn.mojodna.net/repository/acts_as_searchable/trunk
Query Analyzer
  Info: http://www.agilewebdevelopment.com/plugins/show/392
  Install: http://svn.nfectio.us/plugins/query_analyzer
acts_as_solr
  Info: http://www.agilewebdevelopment.com/plugins/show/400
  Install: http://opensvn.csie.org/thiago/rails/plugins/acts_as_solr/
ExceptionTextable
  Info: http://www.agilewebdevelopment.com/plugins/show/268
  Install: http://svn.pinds.com/rails/plugins/exception_textable/
FCKeditor
  Info: http://www.agilewebdevelopment.com/plugins/show/369
  Install: svn://rubyforge.org//var/svn/fckeditorp/trunk/fckeditor
$ rapt install http://opensvn.csie.org/thiago/rails/plugins/acts_as_slr/
+ ./acts_as_solr/CHANGE_LOG
+ ./acts_as_solr/README
+ ./acts_as_solr/init.rb
+ ./acts_as_solr/install.rb
+ ./acts_as_solr/lib/acts_as_solr.rb
+ ./acts_as_solr/lib/templates/solr.yml
+ ./acts_as_solr/schema.xml

All made possible by Ben Curtis’ RaPT tool and the Rails Plugin Directory. Thanks, Ben!

Ben’s Blog Entry on RaPT
RaPT @ RubyForge

Posted in  | no comments

Ruby FlexImage Plugin Now Especially Effective

Posted by Daniel Butler Thu, 26 Oct 2006 20:08:00 GMT

Alex Wayne has updated his FlexImage plugin for Ruby on Rails, and it now allows for all sorts of special effects such as translucent overlays, drop shadows, and borders, in addition to its existing image processing capabilities. The plugin is described as:

“FlexImage is a plugin that allows you to put image data in your database And retrieve at any size, qulaity or cropping you like. Combine this with page caching and you have a fast and easy way to manage large numbers of uploaded images that are always just the right size for your needs.”

As an example, an image can be resized with an added drop shadow with the following snippet:

flex_image  :action => 'show',
            :class  => MyImage,
            :size   => 200,
            :crop   => true,
            :shadow => true

Thanks, Alex!

Alex’s Blog Posting
FlexImage API Documentation
FlexImage at the Ruby Plugins Directory

Posted in  | 1 comment

Exploitable Denial of Service in Ruby's cgi.rb Library

Posted by Daniel Butler Wed, 25 Oct 2006 22:24:00 GMT

Zed Shaw, author of Mongrel, has provided a fix for the exploitable error in Ruby’s cgi.rb library. The error occurs when incorrectly crafted MIME boundaries for multipart uploads causes cgi.rb to loop infinitely waiting for input.

The following servers are affected:

  • Mongrel
  • Lightspeed
  • CGI Standalone
  • Any other server using cgi.rb

If you’re running any of these, you may want to upgrade or patch. More information on the error can be found in Zed’s post to the Ruby on Rails forum.

Posted in  | no comments

Rails Documentation in CHM Format

Posted by Daniel Butler Tue, 17 Oct 2006 15:03:00 GMT

DeLynn Berry from Denver, Colorado, has converted the Rails Documentation to CHM format, which is quite a bit easier to use than the online HTML format. CHM, or Microsoft Compressed HTML Help, is a proprietary format for online help files, but it can be read on other platforms like Linux and Mac with additional software. DeLynn writes of the update:

“This update has the documentation for the 1.1.6 release of Rails. This version also has a much more organized Contents section that has a folder group for each gem, which will hopefully lead to easier browsing of the entire file.”

If you’re on Mac, try Chamonix, which has better search features than Chmox, but both tools work. On Linux, try GnoCHM or KchmViewer.

Link to DeLynn’s Blog Announcement
Direct Link to CHM File

Posted in  | 1 comment

Ruby on Rails date_finder plugin

Posted by Daniel Butler Wed, 20 Sep 2006 13:07:00 GMT

Jonathan Viney of New Zealand has announced his date_finder plugin for Ruby on Rails. The plugin allows the following types of actions:

  • To find the next five Mondays and Fridays:
DateFinderBase.weekly.day(:monday).day(:friday).find(:max => 5)
  • To find the 10th of the month for the next five months:
DateFinderBase.monthly.day_number(10).find(:max => 5)
  • To find the last Thursday in September for the next 3 years
DateFinderBase.yearly.month (:september).day(:thursday).day_occurrence(:last).find(:max => 3)
  • To find the next 5 Wednesdays on a fortnightly basis (skips every second week):
DateFinderBase.weekly(2).day(:wednesday).find(:max => 5)

To install, execute script/plugin install http://svn.viney.net.nz/things/rails/plugins/date_finder.

Thanks, Jonathan.

Date Finder @ Ruby Plugins Directory

Posted in  | Tags  | no comments

Older posts: 1 2 3 ... 8