Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.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 如何将重定向_更改为带有自定义控制器的设备?_Ruby On Rails_Ruby_Devise_Ruby On Rails 6 - Fatal编程技术网

Ruby on rails 如何将重定向_更改为带有自定义控制器的设备?

Ruby on rails 如何将重定向_更改为带有自定义控制器的设备?,ruby-on-rails,ruby,devise,ruby-on-rails-6,Ruby On Rails,Ruby,Devise,Ruby On Rails 6,我使用Desive和自定义控制器(用户控制器)。与其登录并转到user/edit,我更喜欢服务于主页。为此,我需要编辑designe会话create controller方法 我知道我可以按照Deave提供的说明编辑Deave自定义控制器: # before_action :configure_sign_in_params, only: [:create] # GET /resource/sign_in # def new # super # end # POST

我使用Desive和自定义控制器(用户控制器)。与其登录并转到
user/edit
,我更喜欢服务于主页。为此,我需要编辑designe会话create controller方法

我知道我可以按照Deave提供的说明编辑Deave自定义控制器:

  # before_action :configure_sign_in_params, only: [:create]

  # GET /resource/sign_in
  # def new
  #   super
  # end

  # POST /resource/sign_in
  # def create
  #   super
  # end

  # DELETE /resource/sign_out
  # def destroy
  #   super
  # end

  # protected

  # If you have extra params to permit, append them to the sanitizer.
  # def configure_sign_in_params
  #   devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
  # end

那么按照这些说明,我如何让
create
方法准确地执行它当前的操作,但
将\u重定向到“/”
而不是它当前正在执行的操作

注意:这是它目前正在做的事情:

self.resource = resource_class.new(sign_in_params)
clean_up_passwords(resource)
yield resource if block_given?
respond_with(resource, serialize_options(resource))
另外请注意,我可以直接从github上的Desive复制该代码,然后对其进行编辑,如下所示:

self.resource = resource_class.new(sign_in_params)
clean_up_passwords(resource)
yield resource if block_given?
redirect to: "/"

但是我想使用
super
方法来实现这一点,因为这是Deave说明中推荐的方法。

无需重新定义
创建
操作,因为Deave允许您在方法的路径中签名后使用

def after_sign_in_path_for(resource)
  root_path
end

无需重新定义
create
action,因为designe允许您在
方法的路径中对进行签名后使用
action

def after_sign_in_path_for(resource)
  root_path
end
你试过设计助手吗?你试过设计助手吗?