Volker and Sergio,
you guys are incredibly helpful, thank you! I updated to latest git of AS and
failed. The beginning_of_chain seems top work well, but I cannot quite get the
named_scope to work:
With "car" being "catalog_item" and "spareparts" being "Isotype Control" in my
case, I first needed to add a "has_many :catalog_items" to the CatalogItem-
model and then tried:
named_scope :isotypecontrol, lambda { |conjugate, fragment, isotypeh, origin|
{ :conditions => ['markers.name= "Isotype Control" AND
catalog_items.conjugate_id = ? AND catalog_items.fragment_id = ? AND
catalog_items.isotypeh_id = ? AND catalog_items.origin_id = ?', conjugate,
fragment, isotypeh, origin] }
}
catalog_items belongs_to marker, conjugate, fragment, isotypeh, origin (and
unrelated others, like manufacturer) and I'd like the named scope to show all
other catalog_items which have the marker.name = "Isotype Control" and the
same c,f,i and o. I've tried countless examples of the named_scope above,
including the underdocumented :include and :joins directives. Right now, I get
ActiveRecord::StatementInvalid (Mysql::Error: Unknown column
'catalog_items_catalog_items.catalog_item_id' in 'on clause': SELECT
count(DISTINCT `catalog_items`.id) AS count_all FROM `catalog_items` LEFT
OUTER JOIN `markers` ON `markers`.id = `catalog_items`.marker_id LEFT OUTER
JOIN `conjugates` ON `conjugates`.id = `catalog_items`.conjugate_id LEFT
OUTER JOIN `manufacturers` ON `manufacturers`.id =
`catalog_items`.manufacturer_id LEFT OUTER JOIN `origins` ON `origins`.id =
`catalog_items`.origin_id LEFT OUTER JOIN `catalog_items_reactivities` ON
`catalog_items_reactivities`.catalog_item_id = `catalog_items`.id LEFT OUTER
JOIN `reactivities` ON `reactivities`.id =
`catalog_items_reactivities`.reactivity_id LEFT OUTER JOIN `fragments` ON
`fragments`.id = `catalog_items`.fragment_id LEFT OUTER JOIN `isotypehs` ON
`isotypehs`.id = `catalog_items`.isotypeh_id LEFT OUTER JOIN `isotypels` ON
`isotypels`.id = `catalog_items`.isotypel_id LEFT OUTER JOIN
`applications_catalog_items` ON `applications_catalog_items`.catalog_item_id =
`catalog_items`.id LEFT OUTER JOIN `applications` ON `applications`.id =
`applications_catalog_items`.application_id LEFT OUTER JOIN `catalog_items`
catalog_items_catalog_items ON catalog_items_catalog_items.catalog_item_id =
catalog_items.id WHERE (((catalog_items.id = '5'))) AND (markers.name=
"Isotype Control" AND catalog_items.conjugate_id = 1 AND
catalog_items.fragment_id = 1 AND catalog_items.isotypeh_id = 2 AND
catalog_items.origin_id = 1) ):
The error remains the same even for simpler scopes like ":conditions =>
['catalog_items.conjugate_id = 2']". How can I get this to work?
cheers,
ben
--
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en.