Sqlite error only in rails

Hi all,

I have a has_many through relation and have written a scope for that.
I don’t get the joins to work so I wrote the sql for the joins:
scope :has_country_variation_for_country, lambda{|country_id|
joins(‘INNER JOIN variations ON variation_images.variation_id IS
variations.id INNER JOIN country_variations ON
country_variations.variation_id =
variations.id’).where(:country_variations => {:country_id =>
country_id})}

This results in the following sql:
SELECT “variation_images”.* FROM “variation_images” INNER JOIN
variations ON variation_images.variation_id IS variations.id INNER
JOIN country_variations ON country_variations.variation_id =
variations.id WHERE (“country_variations”.“country_id” = 1)

It works perfectly in SQlite Manager and Base but not in rails or the
sqlite3 console!!!
I get "SQLite3::SQLException: near “variations”: syntax error: "
What have i done wrong?

I use sqlite3 (1.3.3)

This is the model:
class VariationImage < ActiveRecord::Base
has_many :country_variations, :through => :variation

Thanks jonas

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs