获取 Devise 的型号名称
我有:
devise_for :users
devise_for :admins
然后,在登录页面上,当有人尝试访问 /admins/sign_in 时,我想显示“管理员登录”标题,
如何做到这一点?
I have:
devise_for :users
devise_for :admins
Then, on Sign In page, i want to show 'Admin Sign In' title when someone tries to access /admins/sign_in
How it could be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用范围视图,它们在设计文档的“配置视图部分”中进行了描述。
运行:
并在
config/initializers/devise.rb
中设置以下内容:然后您可以修改
app/views/admins/sessions/new.html.erb
,这只会以管理员身份登录时使用。如果视图不存在,它将退回到
app/views/devise/sessions/new.html.erb
。Use scoped views, they're described in the devise documentation, in the "Configuring views section".
Run:
and set the following in
config/initializers/devise.rb
:You can then modify
app/views/admins/sessions/new.html.erb
, which will only get used when logging in as an admin.If the view does not exist, it will fall back on
app/views/devise/sessions/new.html.erb
.如果您只是想更改管理登录视图中的页面标题,您可以更改路由文件中的标题,如下所示:
devise_for :admins, :path_names => { :sign_in =>; “管理员登录”}
If you're just looking to change the title of the page in the admin sign in view you could change the title in your routes file as follows:
devise_for :admins, :path_names => { :sign_in => "Admin Sign In" }