# Filter query results from URL hash

**URL:** <https://www.ruby-forum.com/t/filter-query-results-from-url-hash/121838>\
**Category:** Rails\
**Created:** [December 1, 2007, 6:44pm UTC](https://www.ruby-forum.com/t/filter-query-results-from-url-hash/121838 "2007-12-01T18:44:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pootsy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecc23a/32.png) [@Pootsy](https://www.ruby-forum.com/u/Pootsy)\
**Post date:** [December 1, 2007, 6:44pm UTC](https://www.ruby-forum.com/t/filter-query-results-from-url-hash/121838/1 "2007-12-01T18:44:27Z")

</div>

Hi,

I’m developing a very simple product catalogue. Different product  
types and categories for each type.

I’d like to filter the results on my browse controller based on the  
values that have been appended to the URL.

for example

[http://www.shop.com/cataloge/browse](http://www.shop.com/cataloge/browse) would display all products  
[http://www.shop.com/catalogue/browse/?type=NewBook](http://www.shop.com/catalogue/browse/?type=NewBook) would display all  
NewBooks.  
[http://www.shop.com/catalogue/browse/?type=UsedBook?used\_book\_category\_id=4](http://www.shop.com/catalogue/browse/?type=UsedBook?used_book_category_id=4)  
would display all UsedBooks in used\_book\_category 4.

etc.

at the moment in the catalogue\_controller.rb I’m trying

def browse  
@products = Product.find(:all, :conditions =\> params[:product]  
end

how would I get the values from the url loaded into the  
params[:product] variable? And am I correct in thinking that it will  
then pick up the params declared in the URL and automatically filter  
the Products according to the criteria.

I think this can be done, saving a lot of hassle in the long term. Any  
help would be really appreciated.

Philip
