regex - Rails set school attribute based on users email address? -


In my rail app I have a regex which ensures that only @YW.ADU or @Burkley.EU email addresses It can be used on the user's registration. What I want to do now, it is automatically set to the school which user visits on the basis of those domains, which is one of their email addresses. So, if, for example, someone signs up with an @burkelly.edu email, then the school specialty will be set to "University of California, Berkeley" in the user model.

I have tried to do this, but this is a non-trivial problem. It has been told here that the user looks like regex in the model (I have not added the UW.edu yet, but you Get the idea):

  berkeley_regex = / \ a [\ w + \ -] + @ Berkeley \ .edu \ z / i valid: email,: appearance = & gt; True ;: Format = & gt; {: With = & gt; Berkeley_regex} I have already added a "school" column to the user model. If someone can show me what I want to do that will be horrible  

I tried this:

  DIF match match = user ['email']. Match (/? (?? Lt; uw & gt; *? Uw \ .edu) | ((? & Lt; berk & gt; *? Berkeley \ .uu)) / i) school = 'you u' Matches ['u'] Be present School = 'bark' matches ['Berkeley'] is present? End  

and before__development: the match at the top, but it gives me an error

Except for the # class: 0x008fe1a995

Pre-SSA Results Use How do I receive a user's email after signing up?

Why are not you doing before_save hook in

  matches = Counter ['Email']. Match (/? (?? Lt; uw & gt; *? Uw \ .edu) | ((? & Lt; berk & gt; * Berkeley \ .edu)) / i) School = 'U' matches if [ 'U']. is present? School = 'bark' matches ['Berkeley'] is present?  

And did ur?


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -