0

내 장비 설정으로 인해 이상한 일이 발생했습니다.장비의 널 포인터 오류

나는 사용자 정의 동작을 위해 사용하고있는 사용자 지정 ConfirmationsController가 있습니다.

내 고객 모델 :

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 

내 사용자 정의 컨트롤러

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

내 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 

내 경로에 따라이 컨트롤러를 명중 내가 이메일을 입력 파일 . 제출을 클릭하고 리소스에 대한 널 포인터를 가져옵니다. 하지만 리소스 이름은 아닙니다. 누구에게 내가 누락되었거나 고객이 null로 전달할 수있는 아이디어가 있습니까?

답변

0

resource은 어디에도 설정되어 있지 않습니다. default ConfirmationsController에서 (실행중인 버전에 따라)을 처음 상태로이 같은 resource을 고안 :

self.resource = resource_class.send_confirmation_instructions(resource_params) 

당신이 전에 puts 문을 super를 넣어 경우, resource 설정해야합니다.

+0

나는 두려워하지 않을 수 있습니다. super가 호출되면 널 포인터 예외가 호출됩니다. super 메소드가 뒤 따르는 create 메소드만으로도 이런 일이 발생합니다. 그러나 주목할 가치가있는 점은 resource_params도 제로라는 것입니다. – OVERTONE