#53 ✓resolved
Scott

order_by_links

Reported by Scott | February 17th, 2009 @ 11:57 PM

I am trying to do some multi-column sorting and tried the order_by_links. Kept getting the error "links_option" not defined. Looking into the code: C:\ruby\lib\ruby\gems\1.8\gems\searchlogic-1.6.3\lib\searchlogic\helpers\control_types def order_by_links(options = {})

      add_order_by_links_defaults!(options)
      links_options = options.deep_dup
      links_options.delete(:choices)
      html = ""
      options[:choices].each do |choice|
        link_options = links_option.deep_dup
        text, value = option_text_and_value(choice)
        link_options[:text] ||= text
        html += order_by_link(value, link_options)
      end
      html
    end

Should be: def order_by_links(options = {})

      add_order_by_links_defaults!(options)
      links_option = options.deep_dup
      links_option.delete(:choices)
      html = ""
      options[:choices].each do |choice|
        link_options = links_option.deep_dup
        text, value = option_text_and_value(choice)
        link_options[:text] ||= text
        html += order_by_link(value, link_options)
      end
      html
    end

This also looks to be in "order_as_links" and probably others. Now, once I did that it worked, but not as expected. My code is:

I expected to have a column titled "Family" that when I click on would sort by :initials, and then by :hide. But what I got was a single column with "Family Family" and just the initials, when I click on the first "Family" it sorts by initials, and when I click on the second "Family" it sorts by the :hide -which is actually in another column.

Thanks, Scott

<%= order_by_links(:choices => [:initials, :hide], :text => "Family", :html => {:class => "linkth"}) %>

Comments and changes to this ticket

  • Ben Johnson

    Ben Johnson March 6th, 2009 @ 05:34 AM

    • State changed from “new” to “resolved”

    I fixed this bug and pushed it out, but order_by_links will produce a link for each choice and then toggle ASC and DESC. If you want to have one link that toggles itself you are going to have to roll your own solution since that seems like an application specific problem. Regardless, creating your own links is very easy, look at order_by_link to see what I mean:

    order_by_link(:initials)

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Provides common named scopes and object based searching.

People watching this ticket

Pages