rails named_scopes joins


i'm perplexing emanate named_scope uses join, nonetheless nonetheless generated sql looks right, outcome garbage. example:



class trim < activerecord::base      
named_scope :visible, {
:joins => "inner join array series.id = clips.owner_id middle join shows shows.id = series.show_id",
:conditions=>"shows.visible = 1 clips.owner_type = 'series' "
}


(a trim owned series, array belongs show, arrangement manifest invisible).



clip.all does:



select * `clips` 


clip.visible.all does:



select * `clips` middle join array series.id = clips.owner_id middle join shows shows.id = series.show_id where (shows.visible = 1 clips.owner_type = 'series' ) 


this looks okay. nonetheless indirect array trim models includes trim an id that's database - it's picked adult arrangement id instead. where am i going wrong?



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members