Last active
August 29, 2015 14:00
-
-
Save ndrluis/11159876 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SignupController < ApplicationController | |
| def new | |
| @user = User.new | |
| end | |
| def create | |
| @user = User.new(user_params) | |
| if @user.save | |
| redirect_to login_path, | |
| notice: t("flash.signup.create.notice") | |
| else | |
| render :new | |
| end | |
| end | |
| private | |
| def user_params | |
| params | |
| .require(:user) | |
| .permit(:name, :email, :password, :password_confirmation) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class User < ActiveRecord::Base | |
| validates_presence_of :name | |
| validates_format_of :email, with: /\A[a-z0-9_.+]+@[-a-z0-9.]+\.[a-z]{2,4}\z/i | |
| validates_uniqueness_of :email | |
| has_secure_password | |
| has_many :tasks | |
| def pending_tasks_count | |
| tasks.pending.count | |
| end | |
| def done_tasks_count | |
| tasks.done.count | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment