Thanks Niki. Yeah, that helps, but I was really hoping to use a drop
down. Using links works, but I don't really like creating new urls
for a simple sorting. In my experience, it's bad practice to have new
urls for the same content because google / search bots will spread
your "juice" to each sort option.
Any how, this is what I attempted to do:
Added a hash to the Taxons Controller via class_eval
@sort_options = {
"Most Popular" => "descend_by_popularity",
"Name: A to Z" => "ascend_by_name",
"Name: Z to A" => "descend_by_name",
"Price: High to Low" => "descend_by_master_price",
"Price: Low to High" => "ascend_by_master_price",
}
Then I created the following drop down that renders on Taxons#show
<% form_for :taxon, :url => seo_url(@taxon) do |f| %>
<%= select_tag 'product_group_query',
options_for_select(@sort_options.each_pair { |key, value|
[key,value] }), :onchange => "this.form.submit();" %>
<% end %>
Here's the interesting part, the "ascend_by_WHATEVER" works, but the
the "descend_by_WHATEVER" gives me the following Exception:
NoMethodError (undefined method `pop' for
"descend_by_popularity":String):
spree (0.11.0) app/models/product_group.rb:76:in `from_route'
spree (0.11.0) lib/spree/search.rb:23:in `retrieve_products'
spree (0.11.0) app/controllers/taxons_controller.rb:13:in
`load_data'
I wonder if I'm doing something wrong or maybe something got screwed
up via implementation of the site. Maybe I should abandon my idea,
but it seems like you should be able to post to the taxons controller
witha a "product_group_query" parameter and have it sort.
Has anyone else tried this? Am I nuts for attempting this?
-Scott