I'm creating a new record in Company table based on the logic below:
if company.nil?
Company.create!(name: User.get_company_name(self.email)), domain: User.get_domain(self.email))
end
I want to extract the name of the domain to place in the Company table. Ie. If I have [email protected], I want to use regular expressions to substitute in 'Nike' as the company name. Or, in the case of [email protected], I'd want the company name to be 'Ryandrake'.
I already have this method I am using to extract the domain, but haven't managed to edit it to extract the name:
def self.get_domain(email_address)
email_address.gsub(/.+@([^.]+.+)/, '\1') // Returns 'nike.com' or 'ryandrake.com'
end
Any help with modifying the method above to just return 'Nike' or 'Ryandrake' would be super helpful!