This doesn't answer your question, but have you thought about storing the position as an integer in the database? Would that be an option? Depending on what you want to do, it might be over-engineering, but it could simplify the view. If you had a position column, you might do something like this:
In the controller:
# Margarita (position == 1), Bourbon (position == 2), Beer (position == 3), and so on@cocktails=Cocktail.order(:position)
In the view:
<%=render@cocktails%><!-- or --><%@cocktails.eachdo|cocktail|%><%=cocktail.name%><%end%>
It might be something to take a look into as you think about drink groups.
Ryan is an engineer in the Sacramento Area with a focus in Python, Ruby, and Rust. Bash/Python Exercism mentor. Coding, physics, calculus, music, woodworking. Looking for work!
This doesn't answer your question, but have you thought about storing the position as an integer in the database? Would that be an option? Depending on what you want to do, it might be over-engineering, but it could simplify the view. If you had a position column, you might do something like this:
In the controller:
In the view:
It might be something to take a look into as you think about drink groups.
That makes sense! It’s a good solution. I’ll look into it. Thanks!