Rails: "500 - Internal server error" caused by error in application.rb

Today, while working on my Ruby on Rails project, I got a "500 - Internal server error" page soon after I tried to run the project after running a migration. There was nothing else on the screen except for that one line.

I tried a few things, like restarting NetBeans, and opening another project to see if the problem was with my Ruby installation. (Other projects were running fine, so the problem wasn't with Ruby.) I even tried running the project from another desktop, getting the same 500 error.

Finally, I did the one thing that I should have done first - checking the development log file. There I found that the problem was a tiny bit of buggy code in the application.rb file that was stopping the project from initializing properly. And because the application failed to initialize, I wasn't getting those detailed error messages that I'm so familiar with.

Have you done something so stupid while developing an application? Forgetting to look at the first place where you could have spotted the problem and instead wasting an hour theorizing about what could be causing the problem?
[Read more...]

IE6 No More - Let's Kill IE6

Microsoft recently made an announcement saying that they will continue to support IE6 until August 8, 2014. That's another 5 years. Can you imagine that? Another 5 years of supporting IE6 when HTML5 and CSS3 are just around the corner.

If you are a web developer, you probably hate IE6 as much as I do (or even more, if that much hate is ever possible). And like me, you are waiting for the day when the damn thing disappears off the face of the internet.

When I started this blog, I had planned to make it completely inaccessible to IE6 users, and instead display a message asking them to switch to some other browser. But then I realized that it's too much effort to hack the template for the sake of spreading the message to the 1% of visitors of this blog who still use IE6.

Instead, I chose to leave all the IE6 bugs unfixed (this template looks awful on IE6) and added the banner from the IE6 No More campaign. "IE6 No More" is a campaign by a group of startups that are fed up with the ancient browser and want it to disappear. Do take a look at their website where they make a very good case against IE6.

However, there's hope for us yet. Digg has restricted access to some of its features on IE6, Facebook is asking IE6 users to upgrade and YouTube will drop IE6 support very soon. If more big websites will also take steps in this direction, we won't have to wait till 2014 for IE6's death.


What browser do you use? Do you think all website should follow Facebook's lead and ask users to upgrade?

If you are a developer, how much of you time is wasted fixing all those IE6 bugs? Have you worked on any website recently where you didn't need to make it compatible with IE6?

PS. If you are a Firefox person and have your own website, why don't you help spread the word about Firefox? The more IE6 users we convert, the better! ;-)
[Read more...]

How to create a simple datepicker using jQuery

jQuery allows you to easily create a datepicker and customize it according to your requirements. Here's a quick look at how you can get started with using the jQuery datepicker.

The jQuery website has a nice application called Themeroller that lets you customize the interface for jQuery UI widgets. There are also plenty of themes available in the gallery that you can download and use directly. Copy the stylesheet, images, the jQuery file and the jQuery-UI files into the appropriate directories and link them in the header of your HTML file.

Now let's create a simple form that contains the text field that you want to convert into a datepicker.

<form action="index" method="get">
  <input id="date-pick" name="date-pick" type="text" value="" />
  <input id="date-submit" name="date-submit" type="submit" value="Go!" />
</form>

To convert the input field with the id date-pick into a datepicker, write the following jQuery code in the head section of your HTML.

$(function(){
  $("#date-pick").datepicker();
});


That's it! The input field that you created now works as a popup datepicker. A calendar showing the current month appears whenever you focus on the #date-pick field and the date you click on appears as text in the field.

There are tons of options to customize the datepicker, such as changing the date format sent to the server or using a different language for the calendar. You can explore these options in the jQuery UI documentation for the datepicker.
[Read more...]