问题描述
在设计中,许多教导如何完成某些事情的页面需要编辑会话控制器。我使用此)它没有过去制作会话控制器如何做一个(如果这很容易对不起,只是给我几个简单的步骤)
In devise, many of the pages that teach how to accomplish certain things require editing a sessions controller. I set up devise using this https://github.com/fortuity/rails3-subdomain-devise/wiki/Tutorial-(Walkthrough) It didn't go over making a sessions controller. How do I make one. (If it's really easy i'm sorry, just give me the few simple steps)
推荐答案
使用 rails g controller MySessions
创建Sessions控制器改变它继承自 ApplicationController
到Devise Controller,如下所示:
Create your Sessions Controller with rails g controller MySessions
. Then inside of your controller change it from inheriting from ApplicationController
to the Devise Controller like so:
class MySessionsController < Devise::SessionsController
#your session logic here
end
您想要覆盖的控制器中的任何逻辑都可以通过调用该方法并插入自己的逻辑来覆盖。对于控制器中的内容,您可以查看它们的代码页面。如果你不想覆盖他们的方法,你可以让他们离开,或者只是调用super。
Any of the logic within that controller that you want to override you can override by calling that method and inserting your own logic. For the list of what's in that controller, you can view the code on their Github page. If you do not wish to override their methods you can either leave them out, or just call super.
def new
super
end
这篇关于Rails设计会话控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!