Class: AuthHelpers::Controller::Confirmable

Inherits:
ApplicationController
  • Object
show all
Includes:
Helpers, InheritedResources::BaseHelpers
Defined in:
lib/auth_helpers/controller/confirmable.rb

Instance Method Summary collapse

Methods included from Helpers

included

Instance Method Details

#create(options = {}, &block) ⇒ Object Also known as: create!

POST /account/confirmation POST /account/confirmation.xml



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/auth_helpers/controller/confirmable.rb', line 22

def create(options={}, &block)
  object = get_or_set_with_send(:find_and_resend_confirmation_instructions, params[self.instance_name])

  if object.errors.empty?
    set_flash_message!(:notice, 'We sent confirmation instructions to your email, please check your inbox.')
    respond_with_dual_blocks(object, options, true, block) do |format|
      format.html { redirect_to(options[:location] || url_by_name_and_scope(:session)) }
    end
  else
    set_flash_message!(:error)
    respond_with_dual_blocks(object, options, false, block)
  end
end

#new(&block) ⇒ Object Also known as: new!

GET /account/confirmation/new



14
15
16
17
# File 'lib/auth_helpers/controller/confirmable.rb', line 14

def new(&block)
  object = get_or_set_with_send(:new)
  respond_with(object, &block)
end

#show(options = {}, &block) ⇒ Object Also known as: show!



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/auth_helpers/controller/confirmable.rb', line 39

def show(options={}, &block)
  object = get_or_set_with_send(:find_and_confirm, params[self.instance_name])

  if object.errors.empty?
    set_flash_message!(:notice, '{{resource_name}} was successfully confirmed.')
    respond_with_dual_blocks(object, options, true, block) do |format|
      format.html { redirect_to(options[:location] || url_by_name_and_scope(:session)) }
    end
  else
    set_flash_message!(:error, object.errors.on(:perishable_token))
    respond_with_dual_blocks(object, options, false, block) do |format|
      format.html { render :action => "new" }
    end
  end
end