- We design and build extraordinary applications for companies looking to make the next great idea a reality.
- learn more
Making acts_as_ferret, STI, and DRb Work Together
If you are using ferret to index a base class which has subclasses using STI, you may have seen the following error once you start using the DRb server which ferret uses for production mode:
undefined method `[]' for #<DRb::DRbUnknown:0x2501bd4>
A quick google on this error will reveal a simple fix; however, this fix might not work for you (it didn't for me). My problem was a result of using the :models option when invoking #find_ids_with_ferret. Fortunately, there is a relatively simple workaround to make ferret play nicely in this scenario.
Topics: ferret, Ruby on Rails, STI
Mass Assigning Inheritance Column Values for ActiveRecord STI with Rails
One of the security features in Rails is to prevent mass assigning values for certain columns (when passing a hash to #new, #attributes=, and #update_attributes). This is to ensure that a malicious user can't exploit the system by passing in values for certain attributes you really don't want them to change.
In Rails 2.1, one of the attributes that will always be protected from mass assignment is the inheritance_column. In most cases, protecting inheritance_column; is desired because we don't want (for example) someone to change their user type by specifying type = 'Admin' when posting a form. Despite this, there are some cases where we do want to allow the user to specify the type.
However, even if we specify #attr_accessible on the inheritance_column, we will not be able to mass assign a value to it. Rails will not allow it unless we put in a little hack to work around this feature.
Topics: activerecord, Ruby on Rails, STI
Multiple Column Sorting with Drag and Drop using Scriptaculous
The other day I wanted to do drag and drop between multiple columns using scriptaculous. Allowing this behavior is extremely simple, but out of the box the interaction feels clunky. Here, we'll be going through an example of how to do multi-column drag and drop with scriptaculous.
Enabling multi-column drag and drop just involves setting a single option, but without setting a few other options the dragging will feel jittery and won't allow us to drop on empty areas. Also, interaction with the server will require a small bit of consideration to support persistence of any changes.
Topics: Javascript, Ruby on Rails, Scriptaculous
Visualizing Your Database Schema Entirely in Rails
I was recently looking into a tool to visualize the schema in a rails app, and found mostly windows only solutions. Some of these included two steps: one to convert your schema into another format (usually XML) and another step which included using a windows only executable to convert that into a diagram.
However, among these I found an interesting plugin which would allow you to not only view your schema live in your application, but also to make changes to it.
Topics: Ruby on Rails
Progressive Enhancement with Prototype and Custom HTML Attributes
One of the nifty things progressive enhancement can be used for is to allow you to markup your document in a way which allows behaviors to be added to it automatically. Most commonly, this is done by specifying a class name on those elements that you want to enhance. However, this approach does not let you easily pass additional information such as parameters to your enhancement code.
An approach to this problem is to use HTML attributes to mark elements, and Prototype makes this technique easy to implement and work across browsers.
Topics: Javascript, Progressive Enhancement, Prototype
Combine Multiple CSS/JS Files Into a Single File in Rails
One of the nice features in rails that many people overlook is the ability to combine multiple CSS or javascript files into a single file. Why would you want to do this? Well, it results in fewer HTTP requests being made by a client. The end result is that the page will load faster in most browsers, and your YSlow score will be bumped up a bit.
How do you turn this feature on? It is simple really; it just involves setting a single option in two rails helper calls which you're most likely already using.
Topics: Ruby on Rails
Separating Source and Test Code With FlexUnit and Antennae
In most projects, people tend to separate source and test code into separate directories. However, out of the box, FlexUnit with Antennae is geared toward a single directory which contains all source and test code. I didn't really want to mix everything together like this, so I modified Antennae to work with a separated structure. Here is the quick and dirty on getting it to work (assuming you're using FlexUnit .85 and Antennae 1.2.0)
Topics: actionscript, antennae, Flex, flexunit
Using ActiveRecord and Metaprogramming to Define Constants for Enumerated Types
Have you ever stored your application's enumerated types in a database? If you have, you might have also noticed that code will often times "duplicate" this data by defining constants or enums that reference what is in the database. If you're anything like me, this duplication does not feel right.
With the metaprogramming capabilities of Ruby, we can address the maintenance costs of duplication by generating these constants at runtime.
The Problem of Encoding H.264 In a Flash Client
Flash Player 9 introduced the ability to decode H.264 video format. However, it cannot encode video as H.264 (although it does encode as H.263).
This is a problem for people who want to take advantage of H.264's ability to encode at a higher quality with a lower bitrate. There are a few vendors out there who propose to offer a solution, but some of the solutions require an extra download which isn't necessarily cross platform.
With the release of AIR, Adobe seems to be targeting the Desktop market as one of their future goals. Many existing desktop applications already support H.264 encoding (see iChat for a good example). If Adobe wants to keep up with the desktop application market, it might be prudent to add support for encoding as H.264 soon.
Topics: Web/Tech
About Pathfinder
Recent
- Making GWT JSON not Quite so Painful
- IDEA - preconference workshop 06 Oct 08
- HTML5, Ajax history management, and The Ajax Experience 2008 Boston
- A Look Back At Past Posts
- Flash Player on iPhone gossip
- Microsoft to Jump on Board EC2
- TAE Boston 2008: The Unsexy Presentations
- The Ajax Experience 2008: Hope to see you in Beantown
- TankEngine: New plugin for Rails iPhone Development
- Symphony of Ruby on Rails and Flex through RubyAMF
Archives
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006







