问题描述
有没有办法自定义设计控制器,因为我们可以使用rails g devise:views生成器命令来修改设计视图。 ??
此处的目的是为用户注册后立即为当前用户创建一个统计表格的行。
我为每个用户维护了用户统计信息。我只是当用户注册我的网络应用程序时,希望在后台触发userstats控制器的create方法。
有没有办法呢?
您需要创建自己的控制器,继承自Devise。
class Admins :: SessionsController< Devise :: SessionsController
end
然后你告诉设计使用该控制器:
devise_for:admins,:controllers => {:sessions => admins / sessions}
将您的视图从设计/会话复制到管理员/会话。 / p>
您可以在这里阅读:
Is there a way to customise the devise controllers , as we can modify the devise views using the "rails g devise:views" generator command. ??
Ok purpose here is to create a statistics table's row for the current user as soon as a user is registered.
I have a user statistics maintained for every user.I just want to trigger the create method of the userstats controller in the background when a user sign-up for my web app.
Is there a way to do this ?
You need to create your own controllers inheriting from Devise's.
class Admins::SessionsController < Devise::SessionsController
end
Then you tell devise to use that controller:
devise_for :admins, :controllers => { :sessions => "admins/sessions" }
And copy your views from devise/sessions, to admin/sessions.
You can read it here: https://github.com/plataformatec/devise
这篇关于我想定制devise宝石的控制器,是可能的,怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!