Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User < ApplicationRecord
- before_save { self.email = email.downcase }
- VALID_EMAIL_REGEX = /A[w+-.]+@[a-zd-]+(.[a-zd-]+)*.[a-z]+z/i
- validates :email, presence: true, length: { maximum: 255 },
- format: { with: VALID_EMAIL_REGEX },
- uniqueness: { case_sensitive: false }
- has_secure_password
- validates :password, presence: true, length: { minimum: 6 }
- end
- def create
- @user = User.new(params[user_params]) # Not the final implementation!
- if @user.save
- #TODO make view
- redirect_to root_path
- else
- #TODO make error messag
- redirect_to root_path
- end
- end
- private
- def user_params
- params.permit(:email, :password)
- end
- $("#signupBtn").click(function(){
- var email = $("#email_sup").val();
- var password = $("#p_sup").val();
- var passCon = $("#pc_sup").val();
- var d = {
- 'email': email,
- 'password': password
- };
- $.ajax({
- type: "POST",
- url: "/users",
- data: d
- }).success(function(json){
- console.log("success", json);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement