registration forms and foreign keys in Rails -


OK, I have something clear here, but here goes:

I created a user

I made a user_goals model with four goals

I created a user_goal_id field in the user table.

In my user registration form, I want to present a collection_select of four possible goals, and when a user is created, then the user enters the ID to the selected target in the table.

I do not understand how to do this. Specifically, I can not understand how to write the selected ID for the user_goal_id field in the user table.

EDIT:

Do I need to make user-controlled controller, or can I just put the controller argument in users_controller?

Please ask the exact question, it is very common to give parts of your code and ask for something exact, If you do not really understand what you are asking, then those who try to answer you will not understand. Please refer to the Rail Guide, a good chapter on the ActiveRecord relationship (which is wrapping the foreign key) and some teototals once you understand how it works, if you need an accurate message error message or code, Please come back and ask your questions, you will have an instant reply, I am sure :)

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -