Category: Ruby On Rails

Ruby on Rails, often shortened to Rails or RoR, is an open source web application framework for the Ruby programming language.

Loading Javascript dynamically using jquery

If you are creating a web application, then your web pages may have all possibilities of being overwhelmed with a number of JavaScript files. Including large number of JavaScript files may slow down your web page. So its a good idea to load JavaScript dynamically to your web page, i.e load them only when these …

Continue reading

Permanent link to this article: https://blog.openshell.in/2011/06/loading-javascript-dynamically-using-jquery/

Guide to MySQL database Engine.

A MySQL database gives you a choice of database engines and an easy way to switch them. Default MySQL Engine would be enough for most of your application but in certain circumstances where the other available engines may be better suited to the task at hand. Choose your engine The number of database engines available …

Continue reading

Permanent link to this article: https://blog.openshell.in/2011/06/guide-to-mysql-database-engine/

Clearing Floats with Overflow using CSS

One of the common problems we face when coding with float based layouts is that the wrapper container doesn’t expand to the height of the child floating elements. The typical solution to fix this is by adding an element with clear float after the floating elements or adding a clearfix to the wrapper. But did …

Continue reading

Permanent link to this article: https://blog.openshell.in/2011/05/clearing-floats-with-overflow-using-css/

What is the difference between padding and margins?

Margins and padding can be confusing to the web designer. After all, in some ways, they seem like the same thing white space around an image or object. Padding is the space inside the border between the border and the actual image or cell contents. In the image, the padding is the yellow area around …

Continue reading

Permanent link to this article: https://blog.openshell.in/2011/04/what-is-the-difference-between-padding-and-margins/

Net::HTTP Raw Post Ruby Code

Net::HTTP is still a popular option though it doesn’t have the easiest API to remember. In order to Post & Access posted request object from the ruby script example is shown below: require “cgi” require “uri” require “net/http” #To Post data without form using RESTful Method url = URI.parse(“http://api.domain.com”) begin requestXml = “Johnjohn1234” http = …

Continue reading

Permanent link to this article: https://blog.openshell.in/2011/03/nethttp-raw-post-ruby-code/

Comment multiple lines in ruby

A multi-line comment begins with the =begin token and ends with the =end token. These tokens should start at the beginning of the line and be the only thing on the line. Anything between these two tokens is ignored by the Ruby interpreter. =begin Between =begin and =end, any number of lines may be written. …

Continue reading

Permanent link to this article: https://blog.openshell.in/2011/03/comment-multiple-lines-in-ruby/

Try Catch Finally block in Ruby

This the ruby code which is equivalent of a try/catch/finally block in other languages. #Try catch block Syntax begin somecode() rescue puts “Error #{$!}” ensure this_code_will_execute_always() end # Sample Code f = File.open(“testfile.txt”) begin # .. process rescue # .. handle error else puts “– no errors!” ensure f.close unless f.nil? end

Permanent link to this article: https://blog.openshell.in/2011/03/try-catch-finally-block-in-ruby/

REST methods form request in Ruby On Rails Client

In order to access RESTful web services from Ruby Client script using form request. The method net/http tries to connect over HTTP even of the uri is HTTPS. For HTTPS, You need to explicitly tell net/http that a secure connection should be used. REST client code as shown below: # Basic REST. # Most REST …

Continue reading

Permanent link to this article: https://blog.openshell.in/2011/03/rest-methods-form-request-in-ruby-on-rails-client/

Random Image Rotation in ROR

It’s pretty easy to accomplish random image rotation in ROR. This is a simple example of how it can be done, and of course there are ways to make it better (for example, this snippet will only rotate and display .jpg, .gif, and .png files). First, create a folder – let’s name it “rotate” – …

Continue reading

Permanent link to this article: https://blog.openshell.in/2011/01/random-image-rotation-in-ror/

How to Use External Font

Using External Font is very Easy 1.Download the font 2.If the Downloaded font is in ttf format convert it into eot format by a tool which you have to search and download or use this online convertor    http://www.kirsle.net/wizards/ttf2eot.cgi 3.If the Downloaded file is in otf format convert it into ttf format and then convert …

Continue reading

Permanent link to this article: https://blog.openshell.in/2011/01/how-to-use-external-font/