Programming



Image handling in RoR API using Paperclip

 by Nisha  on   13 Aug 2010

Image handling is a common task in an application and for Ruby on Rails we have quite a few plugins like rmagick, minimagick, paperclip, attachment-fu etc available to effectively do the same. Paperclip is by far the most loved and popular plugin used to attach images to a model in a rails application. It makes life easy with good documentation and screencasts available to guide through. But at an advanced level, the challenge comes in when an api interface to upload and download images needs to be provided for the model. As paperclip does not support this by iteself, and there is not much help or guide available to help solve this problem, this post makes life easier for ROR api developers, who have to provide a way to attach images sent through xml to the model.

Continue reading →



Apache, Passenger and other server alternatives: rails

 by abhishek  on   11 Aug 2010

This post is a part of the series of articles about choices available to a rails developer. Previously we discussed about the choice of databases. This time it is about application and web servers. We can make the choice of an application and a web server separately, but as they are so closely related that it is better to look at them together.


Web Server

It is well known what a web server does, but for starters – the web server receives the HTTP requests first, and then responds by either serving the page requested or directing the request to our rails application server. The major web servers market-share wise (survey graph below) are Apache, IIS(Microsoft), nginx, GWS(Google) and lighttpd. We as rails developers are interested in all these except IIS and GWS. Not IIS because it is closed source and proprietary and not GWS because it is used internally by Google. Apache, nginx and lighttpd are all popular among rails developers.

Apache

apache logo

The most popular web server  in use. It supports a wide variety of features, and is reasonably fast as well. Many of the essential features are provided as compiled modules that extend the core. These include support for server side scripting languages like perl, php, tcl, python; support for authentication; support for ssl and tls  and compression support.

The only issue with apache is that because it is process based, it spawns too many threads when there are too many simultaneous requests. This leads to excessive memory usage, so the performance can drop in restricted environments under heavy load.

Continue reading →



Rails Database Default & Alternatives

 by abhishek  on   06 Aug 2010

This post is a part of the series of articles about choices available to a rails developer. It is inspired by a blog post by Josh Susser, where he asserts that there are too many choices available for a new ruby-on-rail developer now, which can get him scared/confused. This series is not about “choice or no choice?”, and not about “are the defaults correct?”. It just answers the newbie developer’s curiosity of what lies beyond the defaults. Lets begin with databases.

Database

Rails is used for writing database backed web applications using the MVC design pattern. The choice of database depends on the kind of capacity you expect from the database and the budget. If you are developing a large enterprise application, you might need to research Oracle/MS-SQL and the like, along with those described here. Another choice you might have to make is whether to go for a relational DBMS. The rails framework provides adapters (programs that connect your app to the database) for three popular open source relational database management systems – sqlite, mysql and postgresql. So if you are looking for an open source RDBMS, you have have the best to choose from.

Continue reading →