Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/54.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_Devise - Fatal编程技术网

Ruby on rails 重新定义设计用户创建

Ruby on rails 重新定义设计用户创建,ruby-on-rails,devise,Ruby On Rails,Devise,我想在designe中重新定义用户创建,使我能够将数据从Guest用户传输到创建的用户 我可以在我的userscocontroller中重写new和create方法吗 def new @user = user.new end def create @user = User.new(user_params) #method to move data from Guest to new User @user.create end 然后为创建一个new.html.haml表单,该表

我想在designe中重新定义用户创建,使我能够将数据从
Guest
用户传输到创建的用户

我可以在我的
userscocontroller
中重写
new
create
方法吗

def new
  @user = user.new
end

def create
  @user = User.new(user_params)
  #method to move data from Guest to new User
  @user.create
end

然后为创建一个
new.html.haml
表单,该表单接受用户的电子邮件和密码?这样做会弄乱任何类型的设计安全功能等吗?

通常会覆盖默认的设计控制器并向其添加自定义功能。 我认为这将满足您将数据从来宾传输到注册用户的需要


这种方法有很好的文档记录,在StackOverflow中有很多引用。

创建Desive用户的代码在registrations controller下,因此您必须更改这些代码。话虽如此,您还是希望在device/registrations\u controller下复制到您的应用程序,并更新new和create方法。请注意,如果您未使用自定义设计控制器,则会出现这种情况。