好的,我觉得我得到的超级棒 does 独立。基本上在Devise中,如果 Users::RegistrationsController < Devise::RegistrationsController,然后在任何行动,有一个 super 将首先在父级中调用相同命名操作的逻辑 Devise::RegistrationsController在此之前打电话给你写的。
换一种说法...
class Devise::RegistrationsController
  def new
    puts "this is in the parent controller"
  end
end
class Users::RegistrationsController < Devise::RegistrationsController
  def new
    super
    puts "this is in the child controller"
  end
end
# Output if users#new is run would be:
# => "this is in the parent controller"
# => "this is in the child controller"
# If super were reversed, and the code looked like this
# class Users::RegistrationsController < Devise::RegistrationsController
  #  def new
    #  puts "this is in the child controller"
    #  super
  #  end
#  end
# Then output if users#new is run would be:
# => "this is in the child controller"
# => "this is in the parent controller"
我很好奇的是,我看到有些人这样做:
class Users::RegistrationsController < Devise::RegistrationsController
  def new
    super do |user|
      puts "something"
    end
  end
end
我很难把头包裹起来 do block 正在完成。在我的例子中,在创建资源(用户)之后,我想在该资源(用户)上调用另一个方法。 
当前代码:
class Users::RegistrationsController < Devise::RegistrationsController
  def new
    super do |user|
      user.charge_and_save_customer
      puts user.inspect
    end
  end
end
我只是想知道这与做的有什么不同:
class Users::RegistrationsController < Devise::RegistrationsController
  def new
    super
    resource.charge_and_save_customer
    puts resource.inspect
  end
end
如果它有用,我已经包括了父母 Devise::RegistrationsController 代码如下:
def new
  build_resource({})
  set_minimum_password_length
  yield resource if block_given?
  respond_with self.resource
end