Ruby on rails 3.2 从其他某个控制器调用designe资源对象

Ruby on rails 3.2 从其他某个控制器调用designe资源对象,ruby-on-rails-3.2,devise,Ruby On Rails 3.2,Devise,我的应用程序中有密码更新。我必须从其他控制器调用相同的表单。我添加了相同的表单,但它给了我一个错误:未定义的局部变量或“resource”方法。如何从任何其他控制器调用更新密码? 我的表格是: <%= simple_form_for(resource, as: resource_name, url: update_password_registrations_path(resource), html: { method: :put }, remote: true) do |f| %>

我的应用程序中有密码更新。我必须从其他控制器调用相同的表单。我添加了相同的表单,但它给了我一个错误:未定义的局部变量或“resource”方法。如何从任何其他控制器调用更新密码? 我的表格是:

<%= simple_form_for(resource, as: resource_name, url: update_password_registrations_path(resource), html: { method: :put }, remote: true) do |f| %>
  <div class="form-inputs">
  <%= f.input :current_password, required: true, wrapper: :prepend, error: true do %>
    <span class="add-on"><i class="ss-icon ss-key"></i></span>
    <%= f.input_field :current_password, placeholder: "Old Password" %>
  <% end %>
  <%= f.input :password, required: true, wrapper: :prepend, error: true do %>
      <span class="add-on"><i class="ss-icon ss-key"></i></span>
      <%= f.input_field :password, placeholder: "New Password" %>
  <% end %>
  <%= f.input :password_confirmation, required: true, wrapper: :prepend, error: true do %>
        <span class="add-on"><i class="ss-icon ss-key"></i></span>
        <%= f.input_field :password_confirmation, placeholder: "New Password Confirmation" %>
  <% end %>
</div>
  <%= f.button :submit, "Update", class: "btn btn-primary" %>
<% end %>

你的资源就是你所谓的设计资源。所以可能是用户

替换

<%= simple_form_for(resource, as: resource_name, url: update_password_registrations_path(resource), html: { method: :put }, remote: true) do |f| %>



确保在控制器中设置了
@user
。如果是当前用户的表单,您可以将
@user
替换为
当前用户

我认为资源对象的范围不超出设计视图、控制器或模型。请发布一些代码。已更新上述表单的代码
<%= simple_form_for(@user, url: update_password_registrations_path(@user), html: { method: :put }, remote: true) do |f| %>