Typo Category feed

I did not realize that my blog was subscribed over at JavaBlogs.com so when I wrote my recent entry on AAA in rails I was surprised to get a comment like this one and despite the tone he did have a point. I should not have it subscribed at java blogs. The version of Typo I am using did not seem to support category based rss feeds. So I did a quick google for answers and found that others had added support this and it had even landed on the issue tracker . So I had a quick browse and decided it was easier to write myself and added a route and a quick hack to app/controllers/xml\_controller.rb from

def rss
@articles = Article.find(:all, :conditions => published=1,
:order => created\_at DESC,
:limit => config\[:limit\_rss\_display\])
end

to

def rss
joins = nil
conditions = published=1
if params\[:category\]
conditions = \[published = 1 AND categories.name = ? AND
articles\_categories.article\_id = articles.id AND
articles\_categories.category\_id = categories.id,
params\[:category\] \]
joins = , categories, articles\_categories
end
@articles = Article.find(:all,
:select => articles.\*,
:conditions => conditions,
:joins => joins,
:order => created\_at DESC,
:limit => config\[:limit\_rss\_display\])
end

And it took me less than 15 minutes which includes time to go and make a coffee. Now that is why I have come to like rails. I may have been able to do the same in another framework but chances are I would have had to guess the table names, file locations, foreign keys etc. With rails I don’t really have to think if the app follows the conventions.