Pathfinder Blog
Author Archive: Anthony Caliendo

Making acts_as_ferret, STI, and DRb Work Together

Ferret by hyperhaus

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.

Continue reading »

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.

Continue reading »

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.

Continue reading »

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.

Continue reading »

Topics:

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.

Continue reading »

Combine Multiple CSS/JS Files Into a Single File in Rails

File Cabinet (by juan23for)

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.

Continue reading »

Topics:

Separating Source and Test Code With FlexUnit and Antennae

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)

Continue reading »

Using ActiveRecord and Metaprogramming to Define Constants for Enumerated Types

A Code Monkey Writes Enumerated Types for Fruit

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.

Continue reading »

Topics: ,

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:

About Pathfinder

  • We design and build extraordinary applications for companies looking to make the next great idea a reality.
  • learn more

Topics

WordPress

Comments about this site: info@pathf.com