I have a rails 3 app where users select an option from a select input which is stored as an integer. The select input is populated by a :collection with simple_form gem, for a table that I seed. This is working exactly the way that I want.
However, I want to display the name instead of the integer in my views.
Right now I am doing this in the view, which is obviously not a best practice.
<% mfg_num = @product.manufacturer.name %>
<%= "#{ListOfManufacturers.find(mfg_num).name}" %>
So, my question is:
What is the best practice for setting up something so that I don’t need to put this logic in my view? Should it be in the controller? Should in be in the model? And how do I do it?
there’re couple of solutions to this problem, these are:
use instance variable in your controller and use it in the view, smth like
use helper method or method in your model
these’re good practice