生成设备控制器-Rails Devise [英] Generating Devise Controllers - Rails Devise
问题描述
我是第一次尝试设计。我在跟踪链接: https://github.com/ plataformatec / devise 。在这里,我执行了以下命令:
导轨生成设计模型
$当我执行此操作时,将创建模型和视图零件。当我检查路线时,我注意到已创建一个名称为:MODEL的控制器。但是我没有在项目中找到控制器。我的查询是如何找到是否生成控制器并在项目中使用该控制器。
预先感谢。解决方案
设计了许多命令
提供。
rails generate devise:install
-将创建config / devise.rb
rails generate devise User
-将创建db / migration-file-for-user-model
其中的注释代码,如果需要其他模块,则可以注释。 。例如confirmable
,omniauth
等
rails generate devise:views
-将在devise
文件夹中使用app / views / devise / sessions创建所有视图
,app / views / devise / confirmations
,registrations
etc文件夹及其视图。
rails生成devise:views用户
-将创建app / views / users / passwords / $的文件夹c $ c>,
app / views / users / confirmations
..etc而不是上面的devise
文件夹。
rails generate devise:controllers
-将创建所有controllers
.. 类似于上面 ...在此处,它将使用默认的注释代码创建app / controllers / devise / sessions_controller.rb
,您需要对其进行编辑否则,请保留它以用于基本身份验证。此外,还可以最后添加个用户
作用域,以在<$ c $中生成控制器c> controllers / users / 而不是controllers / devise /
您也可以阅读这篇很好的 设计教程 > ..
希望有帮助。
I am trying devise for the first time.I am following the link:https://github.com/plataformatec/devise. Here,i have executed the command:
rails generate devise MODEL
when i have executed this,the model and view parts are created.When i checked the routes,I have noticed that there is a controller created with the name:MODEL.but i didnot find the controller in the project.My query is how can we find whether a controller is generated or not and use that controller in the project. Thanks in advance.
解决方案There are many commands that
devise
provides..
rails generate devise:install
- will createconfig/devise.rb
rails generate devise User
- will createdb/migration-file-for-user-model
which commented code,which you can uncomment,if you need other modules..such asconfirmable
,omniauth
etcrails generate devise:views
- will create all views in thedevise
folder withapp/views/devise/sessions
,app/views/devise/confirmations
,registrations
etc folder and its views respectively.rails generate devise:views users
- will create folder ofapp/views/users/passwords/
,app/views/users/confirmations
..etc instead ofdevise
folder above.rails generate devise:controllers
- will create allcontrollers
..similar to above...here it will createapp/controllers/devise/sessions_controller.rb
with default commented code,which you need to edit else leave it as it is for basic authentication.Moreover,you can also addusers
scope in the end,to generate controllers incontrollers/users/
and notcontrollers/devise/
You may also go through this good devise tutorial ..
Hope it helps.
这篇关于生成设备控制器-Rails Devise的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!