简体   繁体   English

Rails设计会话控制器

[英]Rails devise Sessions Controller

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. 我使用这个https://github.com/fortuity/rails3-subdomain-devise/wiki/Tutorial-(Walkthrough)设置了设计。它没有重新制作会话控制器。 How do I make one. 我怎么做一个。 (If it's really easy i'm sorry, just give me the few simple steps) (如果真的很容易对不起,请给我几个简单的步骤)

Create your Sessions Controller with rails g controller MySessions . 使用rails g controller MySessions创建会话控制器。 Then inside of your controller change it from inheriting from ApplicationController to the Devise Controller like so: 然后在你的控制器里面改变它从继承ApplicationController到Devise Controller,如下所示:

class MySessionsController < Devise::SessionsController

#your session logic here

end

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. 有关该控制器中的内容列表,您可以在其Github页面上查看代码。 If you do not wish to override their methods you can either leave them out, or just call super. 如果你不想覆盖他们的方法,你可以将它们排除在外,或者只是打电话给超级。

def new
  super
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM