I use RVideo gem a lot for a video processing application I have been building in Rails which will be open sourced soon on github. Using the gem you can create a RVideo::Inspector object to gather information about the uploaded file including its fps and content type.

If you use the latest version of ffmpeg (mine is SVN-r16905), I find that I keep getting nil values whenever I run the inspector objects. I googled around and found that this is due to a regular expression mismatch in the source. Change line 53 in inspector.rb in the source to:

metadata = /(Input \#.*)\n(Must|At\sleast)/m.match(@raw_response)

MountView, a questionnaire dispatch and monitoring system of which I am a co-developer has been launched. You can find more information here:

www.mountviewapp.com

This is my second commercial Rails application which is still under heavy development.

The first commercial Rails application which is an implementation of MountView is for EssexKarting. Screenshots and more description coming soon.

P/S EssexKARTING is a bespoke application so sorry can’t provide logins

Hello there. First of all apologies for not posting for a while. I have been busy working on commercial Rails projects for the very first time and as such, that takes precedence. However, I am also aware of the need to keep blogging and keep up the practise more as a note to myself about the things I have encountered through work and also to show potential exmployers that I KNOW WHAT I AM TALKING ABOUT.

To start off 2009, I would like to highlight an interesting error I came across today with regards to using attachment_fu plugin. It is a great plugin for handling file uploads in Rails and there are plenty of resources on the web to get you started. The issue arose when I fired up an old Rails application running on 2.0.2 with a view that uses attachment_fu for uplaods. The following error appears on the console:

NoMethodError in XXXController

undefined method `[]‘ for #<Enumerable::Enumerator……..>

So I upgraded to Rails 2.1 and 2.2 but the error still persisted. It transpired that it is a conflict with the verion of Ruby you have running on your system (I use a MAC running on Ruby 1.8.7.) – it appears to be an issue with Ruby 1.8.7 ’s string methods mdofications.

To fix it simply navigate to vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb and change the following line:


attachment_options[:path_prefix]   = attachment_options[:path_prefix]
[1..-1] if options[:path_prefix].starts_with?(‘/’)

Note that starts_with? is a String method only in 1.8.7. Save an relaunch yor application and all should be well.

I obtained the above from the following google group link:

http://groups.google.com/group/attachment_fu/browse_thread/thread/502dd4504a59c84d

Hope this helps someone – certainly helps me after hours of debugging!

P/S if the above has changed since then please let me know as I may not be the most up to date.

Deploying Rails Part 1

August 31, 2008

It is true that producing a rails application is half the batttle won- there are plenty of resources online and in books to guide a newbie through the process. Deploying a complete rails application is another challenge altogether. It requires a well-thought out plan and having the guts to deal with obscure error messages and grappling with the innards of server OS to get it right. It is an art in itself but it can be mastered by anyone with some patience and willingness to learn to get it right.

The traditional reply which I will provide anyone when ask how to deploy a rails application is to use Apache server as a shared host. However, I have recently discovered there are several disadvantages with this approach:

  1. Apache server requires mod_proxy module in order to run a cluster of mongrel servers. This means a default installation with the module already compiled or having to rebuild the entire server. Most shared host providers will not (in my experience) be willing to do that.
  2. Any changes made to the configuration file require starting and restarting the server which means downtime for your application.
  3. The configuration file (httpd.conf) is confusing – it relies on tags which in my experience is daunting and more error prone than a natural language syntax as in Ruby.

Nginx, is an alternative to Apache and is capable of serving both static(html,css,javascript) request as well as dynamic request by routing it through to a mongrel cluster in the backend. It provides a host of configuration features including fcgi support as well as being able to make those configurations on the fly without having to restart the server! Yes, it means being able to upgrage the entire binary while your application still runs in the background.

Now I have not run any benchmark tests as of this writing but will do in subsequent post as to the speed it handles request but as it stands, a lot of major host providers(Engine Yard) and even some application providers(37signals,wordpress) are using it and commenting on significant improvements on performance.

I have setup nginx as a development server on my macbook and from what I understand by reading the wiki, there are two main approaches to installing it on osx.

  1. Using macports
    (sudo port install nginx)
  2. Downloading the latest stable tarball , extract and compile it.

I tried both approaches and only the first seems to work for me. I will document in a subsequent post as to the result of the second approach.

It would be wise to stop apache server on your localhost if you have it setup previously before installing nginx.

Macports automatically installs nginx executable  into ‘/opt/local/sbin/nginx’. The configuration file is located at ‘/opt/local/etc/nginx/nginx.conf.default’ – you need to copy and rename this file to ‘nginx.conf’ before the server will start else you will get an error message on the terminal saying the conf file is not found.

To start or restart nginx I use the following commands on terminal:

sudo launchctl start org.macports.nginx (to start it)

sudo launchctl start org.macports.nginx (to stop it)

Fire up your browser and type in ‘http://localhost/’ and you should see the following screen appear:

The default configuration points to ‘/opt/local/share/nginx/html/’ but can be changed.

In part 2, I will showcase a configuration for a localhost deployment of a rails application including configuring your own mongrel_clusters.

Here are some links to find out more:

Ezra’s (creator of Merb) tips on running nginx

Official Nginx English wiki (apart from the Russian version- yes nginx was created by a russian)