Skip to content

Instantly share code, notes, and snippets.

@beaucollins
Created November 17, 2009 19:36
Show Gist options
  • Save beaucollins/237195 to your computer and use it in GitHub Desktop.
Save beaucollins/237195 to your computer and use it in GitHub Desktop.
# Example Controller
class SomeController < ApplicationController
def index
@categorized_products = Product.categorized
end
end
# Example view
<h2>Boards</h2>
<h3>Foundation</h3>
<%- @categorized_products['boards/foundation'].each do |board| -%>
<%= link_to(h(board.name), show_board_path(board.name_data)) %>
<%- end -%>
<h3>Mobility</h3>
<%- @categorized_products['boards/mobility'].each do |board| -%>
<%= link_to(h(board.name), show_board_path(board.name_data)) %>
<%- end -%>
# You can access any categorization using
# @categorized_products['category/subcategory']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment