Create a gist now

Instantly share code, notes, and snippets.

class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new params[:user]
if @user.save
format.html do
email = EmailService.welcome_email user
email.deliver
redirect_to @user
end
format.json do
        render :json => @user,
:status => :created,
:location => @user
end
else
format.html do
render :new
end
format.json do
render :json => @user.errors,
:status => :unprocessable_entity
end
end
end
end
class EmailService
def self.welcome_email(user)
email = UserMailer.welcome_email user
email.deliver
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment