See, I don't htink there IS an easier way -- just a Ruby-occluded way called .find_by_sql(["select ..."])
A lot of this syntactic sugar really gets in the way. Rails is great, as a web framework -- far superior to something like Struts. But in the end, it;s back to JRuby, writing the back end in the C-like syntax of Java, and avoiding Ruby and it's idioms, making use of Rails this way. On Nov 22, 10:47 am, Eno <[email protected]> wrote: > On Sun, 22 Nov 2009, RVince wrote: > > I have a problem regarding an algorith, for a record I am looking for. > > I can do it in straight sql statements, but I am certain there is a > > Ruby "idion" for this (which, coming from another language, is the > > hardest thing about this fantastic language, getting a handle on the > > idiomsm the syntactic sugars). > > > Suppose I have a table with > > > channel_id int(11) > > associate_id int(11) > > battingorder int(11) > > > I have an id for an associate ('my_associate_id') and I want to > > determine if my associate is in this table with a given channel_id (my > > channel_id) and if not, to select the associate_id in this list whose > > channel_id matches my_channel_id with the lowest batting order. > > > Doing this in a couple of sql statements is quite trivial -- but is > > there a way to do it in a purely Ruby-like idiom? > > You could look at Ruby DBI or maybe you can use ActiveRecord from Rails. > > -- > A -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" 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/rubyonrails-talk?hl=.

