Jarl Friis <[email protected]> writes:

> Thanks Xuan and Colin for your attention.
>
> Xuan <[email protected]> writes:
>
>> You may try adding a "default_scope :select=>'id, name, etc'  " to
>> your model. This would accomplish what you are looking for,
>
> That was exactly what I was looking for.
>
> My actual implentation looked like this in my AR class
>
>   DEFAULT_SELECT = "#{column_names.reject{|c| c =~ /image/ }.map{|c| 
> "\"orders\".\"#{c}\""}.join(', ')}".freeze
>   default_scope :select => DEFAULT_SELECT

Warning to others:

This is not a good solution, it gives problems upon deploying an
application at a clean environment. The problem arise when doing rake
db:migrate, since column_names tries to get column names from the
database at a time where the table does not exist!

I have not found a better way (yet)

Jarl

-- 
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=en.

Reply via email to