> I would like to write the following sql in Rails form.
>
> SELECT manufacturers.*, manuf_descriptions.* FROM manufacturers INNER
> JOIN manuf_descriptions ON manuf_descriptions.manufacturer_id =
> manufacturers.id WHERE (manuf_descriptions.locale = fr AND
> manufacturers.id = 4)
>
>
> I have tried the following:
>
> find(:first, :joins => :manuf_description, :conditions => {:id =>
> manufacturer_id, :manuf_descriptions => {:locale => I18n.locale}})
>
> but it produces:
>
> SELECT `manufacturers`.* FROM `manufacturers` INNER JOIN
> `manuf_descriptions` ON manuf_descriptions.manufacturer_id =
> manufacturers.id WHERE (`manuf_descriptions`.`locale` = 'en' AND
> `manufacturers`.`id` = '8') LIMIT 1
>
> I am not getting the columns from the table manuf_details.
>
> Any ideas?

Add an :include => :manuf_descriptions to your find call.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to