Ruby on rails 设计:在非设计控制器中使用时,编辑不显示值的注册表

Ruby on rails 设计:在非设计控制器中使用时,编辑不显示值的注册表,ruby-on-rails,ruby,devise,form-for,Ruby On Rails,Ruby,Devise,Form For,我已经将resource helper方法添加到我的设置控制器中,这样我就可以从控制器中更新当前用户。我已经从注册/编辑中获取了的表单,并将其复制到我的设置控制器视图中。我能够成功地更新用户,但现有值不会像打开用户/注册/编辑时那样显示在表单中。显示每个表单的代码相同。我错过了什么 设置\u controller.rb helper_method :resource_name, :resource, :devise_mapping, :resource_class def resource_n

我已经将resource helper方法添加到我的设置控制器中,这样我就可以从控制器中更新当前用户。我已经从注册/编辑中获取了的表单,并将其复制到我的设置控制器视图中。我能够成功地更新用户,但现有值不会像打开用户/注册/编辑时那样显示在表单中。显示每个表单的代码相同。我错过了什么

设置\u controller.rb

helper_method :resource_name, :resource, :devise_mapping, :resource_class

def resource_name
  :user
end

def resource
  @resource ||= User.new
end

def devise_mapping
  @devise_mapping ||= Devise.mappings[:user]
end

def resource_class
  User
end 
设计/注册/编辑.html.erb和general.html.erb

<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>

<div class="field">
  <%= f.label :email %><br />
  <%= f.email_field :email, autofocus: true %>
</div>

<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
  <div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>

<div class="field">
  <%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
  <%= f.password_field :password, autocomplete: "off" %>
</div>

<div class="field">
  <%= f.label :password_confirmation %><br />
  <%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>

<div class="field">
  <%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
  <%= f.password_field :current_password, autocomplete: "off" %>
</div>

<div class="actions">
  <%= f.submit "Update" %>
</div>
<% end %>


目前正在等待确认: (如果不想更改,请留空)

(我们需要您当前的密码来确认您的更改)

我也遇到了同样的问题。问题解决了吗?我也有同样的问题。问题解决了吗?