needing some help to just break down the problem.
I have new users who will put in User.Email in a signup process. (I am using Ruby on Rails).
For any given email, I want to parse out the @domain portion.
I then want to find in a different model, Companies, the company_id with the matching column for @domain.
I want to return that instance, and then pass that value into the User.new
I kind of get what needs to happen at the level described, but need some guidance on the next level down.
I’d do something like this
In user.rb
This will call assign_company before validation when a user is created. Here you check to see that the email has been set and then find the company by extracting the domain from the email.
I haven’t tested this, so it might not work as is, but it should hopefully point you in the right direction.