Er, Thing.column_names saves you the call to map(&:name). Martin Emde Tw: @martinemde
On Tue, Sep 8, 2009 at 12:51 PM, Martin Emde <[email protected]> wrote: > Maybe something like this: > > has_many :things, :select => Thing.columns.map(&:name).reject { |c| c == > "big_column" }.join(", ") > > It's not wonderful but it might work :) > > Even better would be to make a class method on Thing that returns your > typical select string. Don't forget to pass in :readonly => false when you > pass :select. It defaults to making them readonly because it doesn't know if > you're asking for columns that shouldn't be written to the database. > > Martin Emde > Tw: @martinemde > > > > On Tue, Sep 8, 2009 at 12:38 PM, Glenn Little <[email protected]> wrote: > >> >> Anyone know of an elegant way in ActiveRecord to create a relation that >> pulls in all *but* one or two fields? We're dealing with a database >> that's not in our control, and they're scattering blob fields into >> tables. We do queries that pull in lots of records from these tables, >> and having the big blob data transferring all the time when we don't >> usually need it seems wasteful. >> >> I'd like something effectively like: >> >> class Parent < ActiveRecord::Base >> >> has_many :children, >> :do_not_load => 'big_data_field' >> >> I can explicitly name every field except the one by using :select, but >> >> a) there are a ton of fields >> b) that's asking for trouble whenever the remote database adds >> or deletes a field >> >> Have I missed another option to has_many, or maybe some other technique? >> >> Thanks... >> >> -glenn >> >> >> >> >> >> > --~--~---------~--~----~------------~-------~--~----~ SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby -~----------~----~----~----~------~----~------~--~---
