Because you're to cool not to fork the release candidate

Posts Tagged: rails

My latest project - Hyperion

The Git/FTP/SSH/IceCAST/Rails/Samba Server


One of my clients’ site,, is undergoing a full overhaul currently and occupies a lot of my free time. I figure it deserves the occasional blog for updates.


Gnartifact is getting a brand new video archiving form. Before, the site grabbed a lot of data from the Vimeo and YouTube APIs from the Rails backend. In this version, all API calls are done client-side using jQuery. This increases performance and accuracy of archiving.

Select default thumbnails is now even easier as you can now upload your own thumbnails, and all past thumbnails are saved to be chosen from at any point. Customization is the name of the game for this version. Paperclip still powers image uploading.

With the addition of many more video attributes, the archive form is broken into tabs. This makes organization and user workflow much simpler, and makes it easy to enable or disable features on the fly.

Major changes is the upgrade to Rails 3.1 from Rails 2.3. Production server will run on Phusion Passenger instead of a Mongrel cluster. Hosting company will be switched to my own reseller account. RVM is implemented now right in development. A local Git server and Capistrano will be used for deployment. The complete custom administrative end has been replaced with the ActiveAdmin gem, which I really recommend you check out. 

As always, NewRelic will be used for server monitoring. 

More updates to come soon

How to update page views in batches, not every time page loads

We have a high load site that has a forum which has been programmed to increment topic pageview every time that topic page loads. In peak hours these writes become a bottleneck and MySQL gets locked up. Is there a way to keep pageviews in memory and then update once in at an interval (e.g. every minute) in a single query?

Our stack is: Ruby on Rails 2.3.8, MySQL 5.1, Memcached, Nginx + Passenger


How to Detect an Integer in Rails 3 Routes?

I would like to do just a little bit of extra logic in rotues.rb, that probably doesn’t belong there, but it seems to make the most sense to me.

I have two conflicting routes. To be primitive:

match '/videos/:browseby' => 'videos#browse', :as => "browse_by"

Where :browseby is looking for a string, such as “Tags”, to browse videos by tags.

However, (and most probably saw this coming) I also have my basic show resource (again in primitive form):

match '/videos/:id' => 'videos#show', :as => "video"

Where :id is looking for the integer for the video ID.

Is there a way to add a small bit of logic such as…

match '/videos/:id' => 'videos#show', :as => "video", :format(:id) => :integer

(Which is my hypothetical rails syntax, to help show what I’m looking for.)

I know I can munch this in the Controller level, but it makes more sense to me to handle it at the route level.