[colug-432] Ruby ActiveRecord joined tables
Rick Hornsby
richardjhornsby at gmail.com
Tue Sep 15 14:34:15 EDT 2015
> On Aug 13, 2015, at 08:05, Rob Funk <rfunk at funknet.net> wrote:
>
> I wonder if Sequel would be a better fit, since it's designed for use
> outside Rails, though it may have some of the same naming issues as
> ActiveRecord. http://twin.github.io/ode-to-sequel/
Quick followup - was working on a related IRC bot plugin, and need to periodically call the same mySQL database for a simple select. Once you get past that things don't have to be complicated in sequel, it's pretty easy to use - and reduces the amount of code required quite a bit. Instead of a bunch of prepare, execute, bind, etc type stuff -
ds = @db[:SONGLIST].where('artist LIKE ? and title LIKE ?', artist, title)
if ds.count == 1
result = ds.first
return result
end
This does a SELECT * which gets more than I need, but the simplicity outweighs the need to be more field specific in this case.
thanks for the tip!
More information about the colug-432
mailing list