Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用Desive guests gem时如何添加回调?_Ruby On Rails_Devise - Fatal编程技术网

Ruby on rails 使用Desive guests gem时如何添加回调?

Ruby on rails 使用Desive guests gem时如何添加回调?,ruby-on-rails,devise,Ruby On Rails,Devise,从中可以看出,在使用gem时,我应该能够在用户回调中添加一个logging\u。如何以及在何处添加回调?找到了一个示例控制器 在ApplicationController中,您需要定义并设置回调,如下所示: define_callbacks :logging_in_user set_callback :logging_in_user, :before, :transfer_guest_user_actions_to_current_user def transfer_guest_user_ac

从中可以看出,在使用gem时,我应该能够在用户回调中添加一个logging\u。如何以及在何处添加回调?

找到了一个示例控制器

在ApplicationController中,您需要定义并设置回调,如下所示:

define_callbacks :logging_in_user
set_callback :logging_in_user, :before, :transfer_guest_user_actions_to_current_user

def transfer_guest_user_actions_to_current_user
  # todo
end