How do I save the user_id by adding the mail?
For the relationship, you have to save the user_id, but to be more dynamic for the user, I want to the users search other users by the email and rails save the id as usual.
How is it done?
In the views I have:
<div class = "field"> <% = form.label: user_id%> <% = form.text_field: user_id, id%> </ div>
I'm using Devise.
Some ideas to get you going. Add an input field for the email, eg
<% = email_field_tag :email %>.
In the controller (create) action, you can find by email, eg:
user = User.find_by(email: params[:email]).
This is just the basics and should help you move forward. Just let us know if you need more guidance after you tried this.
Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.