not_found('category') unless @categories.include? @category
- @subcategory = params[:subcategory] || @category
@subcategories_per_categories = {}
definitions_per_category.each {|category, definitions_per_subcategories| @subcategories_per_categories.store(category, by_subcategory_name(category, definitions_per_subcategories.keys)) }
+
+ default_subcategory =
+ @subcategories_per_categories[@category].nil? ? nil :
+ ((@subcategories_per_categories[@category].include? @category) ? @category : @subcategories_per_categories[@category][0])
+ @subcategory = params[:subcategory] || default_subcategory
+
@definitions = definitions_per_category[@category] || {}
@definitions = @definitions[@subcategory] || []
end