I'm evaluating porting OBS to rails 3 and while there are
tons of annoying problems, that are ugly to fix but are "just work", I
have a real problem with the now deprecated find functions.
Let's take an example:
attribs.find(:first, :joins => "LEFT OUTER JOIN attrib_types at ON
attribs.attrib_type_id = at.id LEFT OUTER JOIN attrib_namespaces an ON
at.attrib_namespace_id = an.id", :conditions => ["at.name = BINARY ? and
an.name = BINARY ? and attribs.binary = BINARY ?", name, namespace, binary])
That's find_attribute and worked ok in rails 2.3 - it's a pretty huge
join and a rather useless big result, but ok.
Now with rails 3, find(:first) is not only deprecated but also joins
set the result to readonly, so I can't do an update to Attrib.
What I did (after a lot of trial and error and googling around was):
a = attribs.joins(:attrib_type =>
:attrib_namespace).where("attrib_types.name = BINARY ? and
attrib_namespaces.name = BINARY ? and ISNULL(attribs.binary)", name,
a = attribs.where(:id => a.id).first if a && a.readonly?
I found the existing documentating I could find rather unpleasant, they
always only cover simple cases or examples I don't understand ;(
Does anyone have a recommendation for such "at the limits" cases?
To unsubscribe, e-mail: opensuse-ruby+unsubscribe(a)opensuse.org
To contact the owner, e-mail: opensuse-ruby+owner(a)opensuse.org