8Rays Tech Blog


Essential reading for the discerning Rails developer

No finger shall be spared during the typing of this blog.

I am always excited to learn a new programming language or framework. My focus in this post is how to expand the horizons for someone coming new to Ruby on Rails. It’s an incredibly powerful framework and has a huge community pushing it along.

continue reading...

How to implement a Store locator

Recently, we needed to implement a store locator with one of our applications Shop What’s New. You can see the how it turned out on the site (click here and then click on “FIND STORE LOCATIONS” on the right). User can click on any of store locations to center the map on that location, or they can type a search query in the box and map displays the locations closest to that. Try it out!

I will now describe briefly how we implemented this. However, before we start, there is some terminology you should understand since you will encounter them often while working with maps.

continue reading...

Display a spinner on Ajax requests in jQuery and Ruby on Rails

Here’s how you can display a spinner on each Ajax request in Ruby on Rails 3 using jQuery and HTML5 “data-” attributes.

The setup part

//public/javascripts/application.js
//"ajax:beforeSend" and "ajax:complete" event hooks are provided by Rails 3's jquery-ujs driver.
$("*[data-spinner]").live('ajax:beforeSend', function(e){
  $($(this).data('spinner')).show();
  e.stopPropagation(); //Don't show spinner of parent elements.
});
$("*[data-spinner]").live('ajax:complete', function(){
  $($(this).data('spinner')).hide();
});
#app/helpers/application_helper.rb
def spinner_tag id
  #Assuming spinner image is called "spinner.gif"
  image_tag("spinner.gif", :id => id, :alt => "Loading....", :style => "display:none")
end

The effect part

Now in whichever form or link you’d like to add spinner support just add one “data-spinner” attribute and the spinner image.
Here’s an example -

continue reading...

How to create embeddable widgets with Rails

Sometime you have to allow embeddable widgets or badges with your application. Just like Youtube allows you to embed videos or many social networking sites allow embedding badges or buttons with some dynamic information on them.

Embeddable widgets can be constructed using Flash or Javascript. Here we will create an embeddable Javascript widget and demonstrate how to do so in Rails.

continue reading...

How to load dynamic content in a jQuery UI dialog via AJAX

jQuery UI dialog allows you to display any content in a popup box, given the content is already present somewhere within page (e.g., in the DOM tree). However, you may want to display content in a popup box that has to be fetched from the server.

Now, here is how you can display a URL into a modal window (in-page popup) with jQuery UI dialog. Do note that this only works for pages hosted on the same domain because of same origin policy

continue reading...

How to estimate a project

Estimating software projects seem to be something of a black art. A lot of has been asked and written about it. However, there is little bit of a method to it as we figured out over past few years over lot of projects.

Since no two software projects are alike, it is not possible to know, accurately, how long something is going to take in advance. So, the only way to really know is to actually start doing the project. And that’s what we do. Well, sort of.

continue reading...

How to be a better developer: Lessons learned from non-programmers

After several weeks of planning, we finally had Abhinav Saxena our old friend and associate come over and deliver Tech-talk for this week.

Abhinav is a graduate of Computer Science from BITS Pilani. After working with Yahoo and participating in NirmaLabs (at that time India’s premier startup incubator), Abhinav is currently a co-founder and lead developer of ShipX.

continue reading...

Signs of a good developer

If you are a business guy, finding and working with a developer can be a daunting task. Having a developer who understands your vision and works diligently to make that a reality is unfortunately rare. Here are a few characteristics of a good developer:

  • Actively listens to your requirements and then remembers them by making notes. Keeping track of details is one of most important things in engineering and good developers will do that instinctively without you having to ask.
  • Advices you not just on technical things but also typical business requirements. Developers typically have a wide range of experience working with various applications and they develop an acute sense of what works.
  • Prepares a project plan before getting into coding and implementation. Any decently sized software project quickly becomes huge list of things which are under various states of progress: urgent things, planned items, things to do in future and things you are considering but are not sure etc. A good plan is crucial, almost like a compass, in keeping the project on the track.
  • Is available 24×7 for any production related issues. Of course, even developers need to sleep. But, responsible developers will wake up in middle of the night and fix that bug if required.
  • Answers emails and messages promptly. A good developer will even go a step further and ask you for a regular conference to provide you status updates proactively.
  • Honest about mistakes and avoids surprises. Software projects by nature are complex and there are mistakes. Fortunately, they are mostly recoverable. However, you should definitely know about it so that you can assess the state of the project and predict the future progress realistically.
  • Lets you know about holidays and other days-off well in advance so that you are aware of the pace of the project.
  • Sends you an invoice regularly. Good developers are proud of their work and so not shy to charge fairly for it. They are also organized to a fault so they maintain a routine of sending you regular invoices. Its good for you as well since you know about your costs accurately rather than being surprised at the end.

Of course, a lot of other people have also written on this topic. Here are some notable ones:

continue reading...

Entrepreneurship: 9 Lessons Learnt

We had our old friend Mayank Sharma come over and deliver this installment of Tech-talk.

Mayank is a graduate of Computer Science from IIT Delhi. After 8 years of successful career in the corporate world, he finally took the plunge and started smsTweet, mCoupons, mLoyalty and Revu. Here he is sharing, for the first time, the lessons of his journey: both bitter and sweet (well, mostly sweet).

continue reading...

Redirecting www URL requests to non-www URL (and vice-versa) in Rails 3

It is probably not a good idea to have your website reachable from both “www.” URL as well as “non-www” top-level URL. As this diverts traffic (and bookmarks) to two different URIs while also possibly splitting up search-engine’s page-ranking. While “www.” URLs have their own advantages (e.g., familiarity, cookie-less sibling subdomain), non-www URLs take at least one less DNS query to resolve and are shorter.

Here is how to achieve the redirection in Rails 3:

continue reading...

Featured posts

Subscribe to this blog

Blog topics