Saturday, 24 March 2012

Ruby on Rails : How to include a page specific JavaScript file in Rails 3.1?

Rails 3.1 application has a new effective way to include a JavaScript file for a particular page without compromising the loading time by using Asset pipeline.


You all know that  in previous versions of Rails, all assets were located in subdirectories of public such as images,javascripts and stylesheets. With the asset pipeline, the preferred location for these assets is now the app/assets directory.Assets can still be placed in the public hierarchy. Any assets under public will be served as static files by the application or web server.

In production, Rails precompiles these files to public/assets by default. The precompiled copies are then served as static assets by the web server. The files in app/assets are never served directly in production.

Monday, 23 January 2012

Ruby on Rails :Cropping images in runtime using Jcrop & ImageMagick

In the previous post i have mentioned about integrating the Jcrop functionality with ImageMagick to hide the selected coordinates  of  the image using a specific color.But here i  am describing on the core feature of Jcrop i.e cropping the image in runtime with the selected coordinates.Here also , we are using ImageMagick in server side to accomplish the whole process.

You all know that Jcrop is a powerful image cropping engine for jQuery. It’s been designed so developers can easily integrate an advanced image cropping functionality directly into any web-based application without sacrificing their time ,flexibility and performance.
ImageMagick is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of fomats (over 100) like   DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF. We can use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves. ImageMagick have a power full command line tool known as “Convert”. Convert has around 265  options for manipulating images .
So now we are going to integrate this two with Rails ,i wont go in depth of how to create the whole process.
In summery :
  • User choose an image and uploads to a server using paperclip.
  • Wep app shows the images to user and allows him/her to select the desired piece of selection of the image to hide using Jcrop.
  • Using an Ajax post request ,we are sending the parameters (X-cord,Y-cord,Height,Width) to the sever which responsible to crop the portion of the image.
  • The appropriate action in the controller will accept the parameters,and then crop the parameters by using a piece of Image-magic code.

Thursday, 12 January 2012

Ruby on Rails : Image hiding using Jcrop & ImageMagick


You all know that Jcrop is a powerful image cropping engine for jQuery. It’s been designed so developers can easily integrate an advanced image cropping functionality directly into any web-based application without sacrificing their time ,flexibility and performance.
ImageMagick is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of fomats (over 100) like   DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF. We can use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves. ImageMagick have a power full command line tool known as “Convert”. Convert has around 265  options for manipulating images .
So now we are going to integrate this two with Rails ,i wont go in depth of how to create the whole process.
In summery :
  • User choose an image and uploads to a server using paperclip.
  • Wep app shows the images to user and allows him/her to select the desired piece of selection of the image to hide using Jcrop.
  • Using an Ajax post request ,we are sending the parameters (X-cord,Y-cord,Height,Width) to the sever which responsible to hide the portion of the image.
  • The appropriate action in the controller will accept the parameters,and then hide the parameters by using a piece of Image-magic code.

Tuesday, 3 January 2012

Ruby on Rails : Hosting your Ruby on Rails application in Heroku


In my previous post,i have mentioned about creating a Ruby on Rails application using devise,Now in this tutorial we are going to host Ruby on Rails database backed application (Rails community web site) to Heroku.
you all know that Heroku is a polyglot cloud application platform. With Heroku, you don’t need to think about servers at all. You can write apps in the programming language of your choice, back it with add-on resources such as SQL and NoSQL databases.You can manage your app using the Heroku command-line tool and you deploy code using the Git revision control system, all running on the powerful Heroku infrastructure.
We have created our Rails community website application with a MySQL database support.The only problem that you have to face while hosting your application in Heroku is that Heroku doesn’t support MySQL , Heroku only supports PostgreSQL database for your application.
Sign up : 
Before all, you have to create an account in Heroku,
Install the Heroku Toolbelt on your system :
If you are using a Ubuntu/Linux machine,follow the steps below.
$ apt-add-repository 'deb http://toolbelt.herokuapp.com/ubuntu ./'

$ curl http://toolbelt.herokuapp.com/apt/release.key | apt-key add -

$ apt-get update

$ apt-get install heroku-toolbelt