Mailinglist Archive: opensuse-ruby (32 mails)

< Previous Next >
[opensuse-ruby] Arel examples / documentation?

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 = LEFT OUTER JOIN attrib_namespaces an ON
at.attrib_namespace_id =", :conditions => [" = BINARY ? and = 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(" = BINARY ? and = BINARY ? and ISNULL(attribs.binary)", name,
a = attribs.where(:id => 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?

Greetings, Stephan

To unsubscribe, e-mail: opensuse-ruby+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse-ruby+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups