Sha256: ab3c91384a9da16bea2ec0beabe0a2d41992aa15c78417c9b6462d41071b0d15

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 KB

Contents

module Clearance
  module App
    module Controllers
      module UsersController

        def self.included(controller)
          controller.send(:include, Actions)
          controller.send(:include, PrivateMethods)
          
          controller.class_eval do
            before_filter :redirect_to_root, :only => [:new, :create], :if => :signed_in?
            filter_parameter_logging :password      
          end
        end
        
        module Actions
          def new
            @user = User.new(params[:user])
          end

          def create
            @user = User.new params[:user]
            if @user.save
              ClearanceMailer.deliver_confirmation @user
              flash[:notice] = "You will receive an email within the next few minutes. " <<
                               "It contains instructions for confirming your account."
              redirect_to url_after_create
            else
              render :action => "new"
            end
          end
        end
        
        module PrivateMethods
          private
          
          def url_after_create
            new_session_url
          end
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
thoughtbot-clearance-0.4.8 lib/clearance/app/controllers/users_controller.rb
thoughtbot-clearance-0.4.9 lib/clearance/app/controllers/users_controller.rb
thoughtbot-clearance-0.5.0 lib/clearance/app/controllers/users_controller.rb
thoughtbot-clearance-0.5.1 lib/clearance/app/controllers/users_controller.rb
thoughtbot-clearance-0.5.2 lib/clearance/app/controllers/users_controller.rb