Sunday, November 22, 2009

[Rails] Re: What is the Ruby idiom for this?

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 <ra...@bitblit.net> 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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate