1
Loveliness?
I’m trying to build an application in Rails. In it I have a resource where users inform the running time related to a category. Well, I need to perform adding up the total column time running time in order to present to a particular user: "You have already performed a total of X hours of activities".
Another point is that I made the relationship with the model Category by attribute category_id and everything is working perfectly, only that I would like to make it appear in the form through a list of categories (by name) and not have the user type the id of the category to make the relationship.
Hello @utluiz, thank you so much for your help! I’m having a little problem in the list of options, in my case the relationship is by category, so I did:
<%= collection_select(:person, :category_id, Category.all, :id, :name) %>
, but when submitting the form it informs that the Category field cannot be empty, even though I have selected a category. How should I do? PS.: I forgot to mention that I’m starting at Ror.– augustoppimenta
@user5476 I will update the response with some suggestions of what may be.
– utluiz
All right then. Fighting for help!
– augustoppimenta
I analyzed the log and see that it is not saving due to the same person. Then I tried to adjust in the controller but it did not work
params.require(:exercice).permit(:timer, :date, { person: [:category_id] })
– augustoppimenta
Thank you @utluiz! Your help was essential. Hug!
– augustoppimenta
@user5476 Glad you could. I’m sorry I didn’t answer more, but it was all going on at work. Hug.
– utluiz