Bird Stream

Entrepreneurship, development and (sometimes) cycling, often simultaneously, mainly in Nottingham

Add Filters to Views Using Named Scopes in Rails

This really helped me deliver a rather lovely solution to filtering records on Bunch Rides.

http://www.idolhands.com/ruby-on-rails/guides-tips-and-tutorials/add-filters-…

and here’s what I did: http://rides.bunch.cc/clubs/54

and the helper code:

def table_filter(filters, selected_scope)
  content_tag(:div,
    raw(filters.collect { |filter| 
      content_tag(:a, filter[:label], :href => "?show=#{filter[:scope]}", :class => ('selected' if filter[:scope] == selected_scope)) }),  
    :class => 'table-filter')
end

Comments