For robustness, might I suggest adding in a `quote_column_name`
wrapping:
has_many :uncontrollable_things, :select => happy_columns.map{|n|
connection.quote_column_name(n)}.join(", ")
Same "test-free-code" caveat for me :)
On Sep 8, 2009, at 12:53 PM, Nick Zadrozny wrote:
> I think :select is the best you've got for something like this. But
> all hope is not lost. My first stab at such a problem would be to
> use the columns array on the class, like so:
>
> class MagicWidgets < ActiveRecord::Base
>
> has_many :uncontrollable_things, :select => happy_columns.join(", ")
>
> def self.happy_columns
> columns.collect { |col| col.name } - [ "big_ol_blob_1",
> "big_ol_blob_2" ]
> end
>
> end
>
> I haven't tested any of that beyond the columns.collect, so you may
> need to experiment a bit, but maybe it'll help get things going in
> the right direction for you.
>
> --
> Nick Zadrozny
>
> >
--~--~---------~--~----~------------~-------~--~----~
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
-~----------~----~----~----~------~----~------~--~---