我不确定最好的方法是什么,但在某种程度上我有点混淆了自己。我想要做的是管理员进入用户个人资料并修改项目的一种方式。
路线
devise_for :customers, :controllers => {:registrations => 'registrations'}
resources :usermanagements
控制器
class RegistrationsController < Devise::RegistrationsController
def update
# required for settings form to submit when password is left blank
@customer = Customer.find(current_customer.id)
if @customer.update_attributes(params[:customer])
set_flash_message :notice, :updated
# Sign in the customer bypassing validation in case his password changed
sign_in @customer, :bypass => true
redirect_to after_update_path_for(@customer)
else
render "edit"
end
end
def edit
@customer = current_customer
end
end
控制器
class UsermanagementsController < ApplicationController
def index
@usermngmts = Customer.paginate(:page => params[:page], :per_page => 30)
end
def show
@usermngmts = Customer.find(params[:id])
end
end
查看registration/edit.html.erb
# i am trying to designate this one for public view
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
...
<% end %>
这有效
查看 usermanagements/index.html.erb
<% @usermngmts.each do |usrmngmt| %>
<%= usrmngmt.incomplete_name %>
<%= link_to ... i would like to go to the edit of usermanagement controller but get usermngents/userid/edit %>
</div>
<% end%>
不混合这两个控制器的最佳方法是什么