I have to access a wordpress database in rails. Yeah, fun occasions. I have been capable of getting in the blog content ok, but I have to access the "category" for every blog publish. The groups are 2 joins away. The raw sql to access the information is the following:

select term.name from wp_term_relationships rel
inner join wp_term_taxonomy as tt
on rel.term_taxonomy_id = tt.term_taxonomy_id
inner join wp_terms as term
on term.term_id = tt.term_id
where object_id = 123
and taxonomy = 'category';

I curently have a WpTerm and WpPost classes. I have to now learn how to tie these together using AR.

Thanks