0

Something very strange happening with my devise setup.

I have a custom ConfirmationsController which I'm using for custom behaviour with devise.

My customer model:

class Customer
include Mongoid::Document

after_create      :prepare_demo_app

devise :validatable,
       :registerable,
       :database_authenticatable,
       :confirmable,
       :trackable,
       :rememberable,
       :recoverable,
       :mailchimp

## Confirmable
field :confirmation_token,   :type => String
field :confirmed_at,         :type => Time
field :confirmation_sent_at, :type => Time

My custom controller

 class ConfirmationsController < Devise::ConfirmationsController
    def create
        puts "resource #{resource}"
        puts "resource name #{resource_name}"
        super
    end
enter code here

My routes.rb

 devise_for :customers,
               :controllers => {:confirmations => "confirmations" },
               :skip => [:sessions, :passwords], :format => false do
               #... other gets and posts but nothing to do with confirmations 
               #...
    end

When I hit this controller as per my routes file I enter an email. Click submit and get a null pointer for the resources. But not the resource name. Has anyone any ideas what I might be missing or why the customer would be coming through as null?

OVERTONE
  • 11,797
  • 20
  • 71
  • 87

1 Answers1

0

resource isn’t being set anywhere. In the default ConfirmationsController, Devise initialises resource like this (depending on what version you’re running):

self.resource = resource_class.send_confirmation_instructions(resource_params)

If you put super before your puts statements, resource should be set.

Buck Doyle
  • 6,333
  • 1
  • 22
  • 35
  • I'm afraid thats not possible. Once super is called, a null pointer exception is called. Even with just the create method followed by super, this happens. Worth noting however is that resource_params is also nil. – OVERTONE Nov 19 '12 at 12:54