parse_sort_param doesn't handle that situation well, so the controller code ends up looking un-Hobo like.

Here's an example from one of our projects:

  def index
    @scopes = {:include => [:organization, {:user => :state}]}
@scopes[:search] = [params[:search], "users.first_name", "users.last_name", "users.email_address", "organizations.name", "states.name"] if params[:search] if parse_sort_param('user', 'user.email_address', 'user.phone_number', 'organization', 'user.state')
      db_sort_field = {
        "user" => "users.last_name",
        "user.email_address" => "users.email_address",
        "user.phone_number" => "users.phone_number",
        "organization" => "organizations.name",
        "user.state" => "states.name"
      }[@sort_field]
      @scopes[:order_by]=[db_sort_field, @sort_direction]
    else
      @scopes[:order_by]=["users.last_name", "asc"]
      @sort_field = "user"
      @sort_direction = "asc"
    end
@site_users = SiteUser.apply_scopes(@scopes).paginate(:page => params["page"])
   end

A couple of things to note: you need the `include`, and you need to map the rails name to the database column you want to sort on.

Bryan

On 11-04-26 11:46 AM, Donald R. Ziesig wrote:
Hi All, Its me again!

Sometimes beta testers can be a pain in the *, but they often find the
most amazing problems.

I have numerous situations where I want to be able to sort a table-plus
based on the value of a belongs_to field as in:

belongs_to :state_prov
belongs_to :agent

in a simple table-plus header:

Name Address City *State/Prov* PostalCode *Agent*

The correct values appear when the table is displayed, but when the
beta-tester clicks on the header for either of these fields (for
example, they want to sort clients by their state/province or properties
by their listing agent), they get a totally blank rendering.

There is nothing there. No menu, no header stuff, its totally blank!

The generated html is quite simple

<html>
<head></head>
<body></body>
<html>

If they click on any of the other fields, the table is sorted and
displayed appropriately.

Any ideas?

Don Z.

P.S. These fields appear as links in the table. In some cases the link
is rather trivial (e.g. the state/province displays the name and
abbreviation of the state or province). I would like to tell table-plus
to just display these without creating a link.

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

--
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