开发者

Rendering the Devise edit Password Form

I'm trying to render the Devise edit password form within another view because I don't want to duplicate the edit pw logic.

I've tried the following (after generating the Devise views):

<%= render 'devise/passwords/edit' %>
<%= render 'devise/passwords/form' %>

And a number of other variations on render that all seem to give me the same error:

"ActionView::MissingTemplate in foo#foo Missing partial devise/passwords/edit..."

This variation:

  <%= render :file => 'devise/passwords/edit.html.erb' %>

Gave me some hope but the following error:

"undefined local variable or method `resource' for #<#:0x47ef0e0>"

around this line:

<%= form_for(resource, :as => resource_name, :url => pas开发者_运维知识库sword_path(resource_name), :html => { :method => :put }) do |f| %>

That makes me think I'm close (as that is code from the form that I want) but shouldn't that template be using the correct logic from the hidden Devise controller? Or do I need to do something in the routes file to get this to work?

Am I way off?


Try this:

<%= render :template => 'devise/passwords/edit', 
                        :locals => { 
                          :resource => my_user_model_variable, 
                          :resource_name => my_user_model_name } %>

Where:

  • my_user_model_variable could be current_user
  • my_user_model_name could be "User"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜