Advertisement
Guest User

Untitled

a guest
Apr 12th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. class User < ApplicationRecord
  2. before_save { self.email = email.downcase }
  3. VALID_EMAIL_REGEX = /A[w+-.]+@[a-zd-]+(.[a-zd-]+)*.[a-z]+z/i
  4. validates :email, presence: true, length: { maximum: 255 },
  5. format: { with: VALID_EMAIL_REGEX },
  6. uniqueness: { case_sensitive: false }
  7. has_secure_password
  8. validates :password, presence: true, length: { minimum: 6 }
  9. end
  10.  
  11. def create
  12. @user = User.new(params[user_params]) # Not the final implementation!
  13. if @user.save
  14. #TODO make view
  15. redirect_to root_path
  16. else
  17. #TODO make error messag
  18. redirect_to root_path
  19. end
  20. end
  21.  
  22. private
  23.  
  24. def user_params
  25. params.permit(:email, :password)
  26. end
  27.  
  28. $("#signupBtn").click(function(){
  29. var email = $("#email_sup").val();
  30. var password = $("#p_sup").val();
  31. var passCon = $("#pc_sup").val();
  32.  
  33. var d = {
  34. 'email': email,
  35. 'password': password
  36. };
  37.  
  38. $.ajax({
  39. type: "POST",
  40. url: "/users",
  41. data: d
  42. }).success(function(json){
  43. console.log("success", json);
  44. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement