第二个设计模型不使用生成的视图 [英] Second devise model not using generated views

查看:88
本文介绍了第二个设计模型不使用生成的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户和代理模型

I have a User and a Rep model

devise_for :users, :controllers => {:registrations => 'user_registration'}
devise_for :reps

我跑了

rails generate devise:views reps

自定义视图显示在app / views / reps中

The custom views show up in app/views/reps

但代表路径仍在使用内置的设计视图

But the rep paths are still using the built in devise views

Rendered〜/ .rvm / gems / ruby​​-1.9.2-p290 / gems / devise-1.4.9 / app / views / devise / registrations / edit.html.erb

Rendered ~/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.4.9/app/views/devise/registrations/edit.html.erb

而不是生成的reps视图。

Instead of the generated reps views.

推荐答案

只需将视图放在那里,Devise就不会使用它们。您需要将 Devise :: RegistrationsController 指向具有这些视图的右侧控制器,您可以通过调用以下方式来执行此操作:

By simply putting the views there Devise won't use them. You would need to point Devise::RegistrationsController to the right controller which has these views, which you can do by calling this:

 devise_for :reps, :controllers => { :registrations => "reps/registrations" }

这需要在 app / controllers / reps / registrations_controller.rb

 class Reps::RegistrationsController < Devise::RegistrationsController

 end

然后你会看到该控制器使用的正确目录。

You would then have the views in the right directory for this controller to use.

这篇关于第二个设计模型不使用生成的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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