Replace Rails confirm dialog with Bootboxjs

Today, I wanted to use Bootboxjs wonderful alert, confirm box in a project. Though it’s pretty easy to use separately, I, later, wanted to replace Rails default confirm dialog box with the same of bootboxjs. Rails default confirmation box is shown by its built in unobtrusive UJS library. At first, lets see how that works.

link_to 'Destroy', @post, :confirm => 'Are you sure?',:method => :delete, :class => 'btn btn-mini btn-danger'

This will generate markups that looks like:

<a class="btn btn-mini btn-danger" href="/posts/999" rel="nofollow" data-confirm="Are you sure?" data-method="delete">Destroy</a>

Now, when you click the Destroy link, it will first ask you with message “Are you sure?”. If you press “Ok” only then it will proceed. So, you get this confirmation box free :).

However, we are seeing this same confirm dialog for years after years and it’s too boring. I wanted to replace this using bootboxjs sexy dialog boxes that is based on Twitter Bootstrap. I’m already using twitter bootstrap for my project so I’m actually not adding that much overhead. You can include it easily using Twitter Bootstrap Rails gem.

When I wanted to override Rails confirm box, I found the a Gist that worked nicely out of the box.

Continue reading →

Rendering will_paginate links nicely with Twitter Bootstrap

When I was working with Moviemates (my one dream pet project), I had to use will_paginate gem for pagination of the movie listings. As the UI are based on Twitter Bootstrap, the will_paginate links (generated by its view helpers) were looking very ugly. Please check the following screenshot to see how bad it was looking!

I had to google a while for a decent look of these links. I’ve found a very effective but easy fix written by  oparrish and shared here. For your conveniences, the gist is attached here:

Continue reading →