Smoke Signals

Friday, May 06, 2005

More Backpack goodness

While paroosing the random backpack pages I came accross this cool backpack hacks backpack. Although I am not sure using it as a mailing list subscription is a good idea. I like Backpacks send to from email. I might have to try that out on similarthings.com... Someday. But with Rails, things like that aren't too hard to implement.

Tuesday, May 03, 2005

Related Tags and Sub-Selects

I am using a query to fetch related tags to an object. It seemed fast enough but then again, I am the only one using the system right now. Court3nay from habtm.com wrote a good article as to why my way sucked and how to make it better. So here is what I ended up with:

In my application controller I created a helper_method that found all items using the tag in question: items = Item.find_by_sql("SELECT it.item_id FROM items_tags it, tags t WHERE it.tag_id = t.id AND t.id = #{tag_info.id}") then I made an array of the id's: items.each {|item| item_ids << item.item_id} #make an array of each item using that tag. Then I passed that to the model method: find_by_sql("SELECT *, COUNT(it.page_id) AS count FROM items_tags it, tags t WHERE it.item_id IN (" + item_ids.join(',') + ") and viola, a more efficient query by splitting it up into 2.

Monday, May 02, 2005

SimilarThings.com

I am near completion on my personal project. There are a couple of things left to do before I finish the first version of my rails app. I hope people will like it. I am not sure if I am going to open-source it. I still haven't figured out how/if I will end up selling the domain versions. Either way people will be able to create free sites. You will have your own subdomain of similarthings.com so mycoolsite.similarthings.com will be possible.