This is a common problem with table-plus.

I've just had a look at the code and I think we can solve this pretty  
easily by having the order_by scope use default_order (if available)  
instead of name_attribute.

Something like (from the order_by default scope)

                 ...
               elsif type.respond_to?(:table_name)
                 include = field
                 if (order = type.default_order)
                   colspec = "#{type.table_name}.#{default_order}"
                 elsif (name = type.name_attribute)
                   colspec = "#{type.table_name}.#{name}"
                 end
               else
                 ...

Bryan, Matt? Looks OK?

I guess we'd have to be a bit more clever than this if we want to  
support things like "last_name, first_name"

Venka - if this works you'll just be able to add "set_default_order  
"last_name" on GrantWriter.

Tom


On 15 Sep 2009, at 09:02, Venka Ashtakala wrote:

>
> I am using the table-plus tag, and one of the columns in my table is
> called 'grant-writer' which isn't a column but actually a model.  I am
> using the table-plus tag to list Projects and a Project belongs to a
> Grant-Writer.  The GrantWriter model has a function called 'name' but,
> it doesn't have a 'name' field and so there is no 'name' column in the
> database.  When I include :grant_writer as one of the fields in my
> table-plus tag and I try to sort on it, the generated SQL is looking
> for a grant_writer.name column ( which doesn't exist ) and so my page
> crashes.  Is there any way that I can specify that the 'name' column
> should not be used but another column?
>
> Thanks
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" 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/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to