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

问题描述

在设计中,许多教授如何完成某些事情的页面都需要编辑会话控制器.我使用这个 https://github.com/fortuity 设置了设计/rails3-subdomain-devise/wiki/Tutorial-(Walkthrough) 它没有去制作会话控制器.我怎么做一个.(如果真的很简单对不起,请给我几个简单的步骤)

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 控制器 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 设计会话控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 13:37