Rails设计会话控制器 [英] Rails devise Sessions Controller

查看:135
本文介绍了Rails设计会话控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在设计中,教授如何完成某些事情的许多页面都需要编辑会话控制器。我设法使用这个 https://github.com/fortuity / rails3-subdomain-devise / wiki / Tutorial-(演练)它没有改变会话控制器。我如何做一个。 (如果真的很容易,我很抱歉,只是给我几个简单的步骤)

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 。然后在你的控制器里面,把它从 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

您要覆盖的控制器中的任何逻辑可以通过调用该方法并插入自己的逻辑来覆盖。有关该控制器中的内容的列表,您可以在其 Github 页面上查看代码。如果你不想覆盖他们的方法,你可以把它们留下,或者只是调用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设计会话控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆