Skip to content

Commit

Permalink
Add more categories for recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
VeroIsoardi committed Dec 9, 2024
1 parent a3ce33e commit be59e14
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion app/helpers/recipes_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ def category_icon(category)
categories_icons = {
'plato principal' => 'pizza',
'postre' => 'cake',
'snack' => 'cookie',
'desayuno y merienda' => 'cookie',
'snack' => 'popcorn',
'entrada' => 'bowl-steam',
'panificados' => 'bread',
'dips' => 'cheese'
}

categories_icons[category]
Expand Down
2 changes: 1 addition & 1 deletion app/models/recipe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Recipe < ApplicationRecord
has_richer_text :ingredients, store_as: :json
has_richer_text :steps, store_as: :json

enum :category, ['plato principal', 'postre', 'snack'].index_by(&:itself)
enum :category, ['plato principal', 'postre', 'snack', 'entrada', 'desayuno y merienda', 'panificados', 'dips'].index_by(&:itself)

scope :sort_by_title, -> { order(:title) }

Expand Down
2 changes: 1 addition & 1 deletion app/views/recipes/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<div class="my-5">
<%= form.label :category, 'Categoría', class: 'label'%>
<%= form.select :category, options_for_select(Recipe.categories), { prompt: 'A qué categoría pertenece' }, class: 'input mt-2 w-full'%>
<%= form.select :category, options_for_select(Recipe.categories.map {|c| [c[0].capitalize, c[0]]}), { prompt: 'A qué categoría pertenece' }, class: 'input mt-2 w-full'%>
</div>

<div class="my-5">
Expand Down

0 comments on commit be59e14

Please sign in to comment.