设计我的 after_sign_up 成功了。但它无法加载资源

devise's my after_sign_up is worked. But it can not load resource

我在 RegistrationsController 中创建了新的 after_sign_up。 它看起来很有效。
但是报错First argument in form cannot contain nil or be empty.
我可以找到 after_sign_upresourcenil。但是在 after_inactive_sign_up_path_for 的资源是存在的。我怎样才能把 resource 完全变成 after_sign_up


registraions_controller.rb

class Users::RegistrationsController < Devise::RegistrationsController
  before_filter :force_ssl!
  before_filter :require_update_ability, only: [:edit, :update, :destroy]

  def create
    super # Don't fix me!
    puts 'user is created.'
  end

  def after_sign_up
    puts resource
  end

  private

  def force_ssl!  
    if Rails.env.production?
      unless request.host == 'dashboard.userhabit.io' && request.ssl?
        redirect_to :protocol => 'https', :host => 'dashboard.userhabit.io'
      end
    end
  end

  def require_update_ability
    unless can? :update, current_user
      flash[:error] = I18n.t 'messages.not_authorized'
      redirect_to apps_path
    end
  end

  protected

  def after_inactive_sign_up_path_for(resource)
    puts resource
    after_sign_up_path(resource)
  end
end


config/routes.rb

devise_for :users, :controllers => {:registrations => 'users/registrations', :sessions => 'users/sessions', :passwords => 'users/passwords'}
devise_scope :user do
  match 'users/after_sign_up' => 'users/registrations#after_sign_up', :as => 'after_sign_up', :via => :get
end


registraions/after_sign_up.erb

<%= simple_form_for(resource, :as => resource_name, :url => after_sign_up_path(resource_name)) do |f| %>

我不知道为什么。但是 after sign_up 方法使资源为零。所以我资源变量进入实例 class 变量。但是 instance class 变量也是 nil 。所以我通过制作全局变量来解决。然而它并不干净。有人有更好的主意吗?然后我粘贴我的代码。

class Users::RegistrationsController < Devise::RegistrationsController
  before_filter :force_ssl!
  before_filter :require_update_ability, only: [:edit, :update, :destroy]

  $user

  def create
    if after_sign_up_path(resource)
      super
      $user = params[:user]
    else
      super # Don't fix me!
      puts 'else'
    end
  end

  def after_sign_up
    @user = $user
  end

  private

  def force_ssl!
    if Rails.env.production?
      unless request.host == 'dashboard.userhabit.io' && request.ssl?
        redirect_to :protocol => 'https', :host => 'dashboard.userhabit.io'
      end
    end
  end

  def require_update_ability
    unless can? :update, current_user
      flash[:error] = I18n.t 'messages.not_authorized'
      redirect_to apps_path
    end
  end

  protected

  def after_inactive_sign_up_path_for(resource)
    puts 'AfterInactiveSignUp'
    puts resource
    after_sign_up_path(resource)
  end
end