Model Specific Formatted Search Results Using Thinking Sphinx

Having recently implemented Thinking Sphinx on one of my web sites, I thought it would be cool to be able to search every indexed model. With Thinking Sphinx, it’s easy to have a bunch of different classes returned in the results. The tougher part is displaying them in a way that is organized (although admittedly not very DRY).
Read the rest of this entry »

Posted in Rails. Tags: , , . 1 Comment »

Sitemaps On Rails

SEO being an interest of mine, I couldn’t quite wrap my head around releasing a webapp without a sitemap. The problem is that there aren’t any really great sitemap plugins for Rails. Now I will grant that creating a sitemap in Rails is a challenging proposition and one that I would not like to undertake on my own unless absolutely necessary. But I was hoping that there would be a rails sitemap “killer app” like there is with almost everything else in Rails.

So I dove in and tried a few options until I found one that worked. First I wrote some code to generate an XML file and then created a sitemap_index.xml.gz file by hand. This was very kludgy and definitely not a permanent solution. I had also read suggestions about doing it in a sitemap_controller.rb file, but that seemed just as kludgy as using a view to generate the XML. It was then time to explore the plugin world.
Read the rest of this entry »

Posted in Rails, SEO. Tags: , . No Comments »

Custom Google Maps Marker With YM4R_GM

In one my Rails applications, I allow the user to search for surrounding businesses from their current location. I always showed them a You Are Here marker. The issue I had with this was that the marker was always the icon as the search results. Differentiating these markers is actually extremely easy with ym4r_gm plugin.

First thing is to find a custom icon that you want to use. You can just Google for custom Google maps icons. I chose to use their default icon, just in a different blue. (You can download it here so you are working with what I am working with for this example). The next thing I did was to use the Google custom markers web site to find the proper config options for the icon.
Read the rest of this entry »

Posted in Rails. Tags: , , . 2 Comments »

Country-State Select Using Carmen and jQuery

I’ve been wanting to find a way to use drop down menus for countries and their states when they exist. But keeping a list on my own would have been a huge pain in the ass. So rather reinvent the wheel, I found the Carmen plugin for Rails. All I have to do is keep the plugin updated and my list of countries and their states will be kept updated as well.

How do I do all this with unobtrusive Javascript and Rails you ask? Good question. Let me show you. Don’t forget to install the plugin (or use the gem).

Let’s start out by adding the drop down menu to our view. In my case I have it in a partial for the address part of a form. You’ll have to modify this slightly to pick up the values of the form if the partial handles edits as well. This one is just for a new method as it uses a default country of US and its states. Note the div ID here of addressStates; we will be using this later in the javascript.
Read the rest of this entry »

Posted in Rails. Tags: . 4 Comments »