我正在尝试将Devise集成到我的Rails应用程序中,但遇到了麻烦。
我想在我的页面中呈现用户注册表单:
我已经rails generate devise:views
并且得到了:
invoke Devise::Generators::SharedViewsGenerator
create app/views/devise/shared
create app/views/devise/shared/_links.erb
invoke form_for
create app/views/devise/confirmations
create app/views/devise/confirmations/new.html.erb
create app/views/devise/passwords
create app/views/devise/passwords/edit.html.erb
create app/views/devise/passwords/new.html.erb
create app/views/devise/registrations
create app/views/devise/registrations/edit.html.erb
create app/views/devise/registrations/new.html.erb
create app/views/devise/sessions
create app/views/devise/sessions/new.html.erb
create app/views/devise/unlocks
create app/views/devise/unlocks/new.html.erb
invoke erb
create app/views/devise/mailer
create app/views/devise/mailer/confirmation_instructions.html.erb
create app/views/devise/mailer/reset_password_instructions.html.erb
create app/views/devise/mailer/unlock_instructions.html.erb
land.html.haml
= render 'devise/registrations/new'
但是我收到了一个错误:
Missing partial devise/registrations/new with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee, :haml]}. Searched in:
* ".../app/views"
* ".../.rvm/gems/ruby-2.0.0-p0@startupcrawler/gems/devise-1.5.4/app/views"
这也不起作用。
= render 'users/registrations/new'
我配置错了吗?
答案 0 :(得分:5)
要呈现部分,例如users/registrations/view
,相应的文件应在_new.html.erb
文件夹中命名为app/views/devise/registrations
。但是,简单地这样做不会使您的表单在您的目标网页中工作,因为它无法访问资源名称和设计映射。
相反,我认为您可以按照https://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app中的说明在页面中添加表单。虽然有登录表格的说明,但他们也应该为登记表格工作。
答案 1 :(得分:0)
这是'渲染'设计/注册/新'
你错过了's'
答案 2 :(得分:0)
使用:模板 喜欢haml = render:template => '设计/注册/新'