Yes, ORMs are wonderful, once you learn the abstraction layer. But --
and I know some will take offense at this -- there are things to avoid
in learning Ruby, and just use the old tried-n-true (many things, like
using straight Javascript for most of the Ajax-like things you want to
do, or for db-query-b ased algorithms, like I am trying to accomplish
here, sticking with as straight of an sql interface as possible). This
is true of most languages, if you can learn a more generic means of
implementing the language, you are not only up-to-speed faster, BUT,
you generally have a finer-grained control over what you ware
implementing.
The algorithm I am looking to sweeten of:
# Is the associate in the list - if not, make it the person at
the top of the list.
@up = Up.find(params[:id]) #get the individual up record which
has the associate and channel
@associate = @up.associate #specify ref to the associate in question
#see if this associate is in the current list
@Qplayers = Qplayer.find_by_sql(["select * from qplayers where
associate_id=? and channel_id=? and
inlist=1",@
associate.id,@associate.channel_id])
if @Qplayers[0].blank? #if the associate from the up in the row is in
the list, it wont be blank
@Qplayers = Up.find_by_sql(["select * from qplayers where
channel_id=? and inlist=1 order by battingorder ASC",@up.channel_id])
@Qplayer = @Qplayers[0]
@associate = @Qplayer.associate
end
I'm not sure can be more clearly expressed in a "sweeter" way,
especially if the criteria changes in the future -R.Vince