[英]Change password in Devise
EDIT: All I need is render /devise/registrations/edit in /settings/password 编辑: 我需要的是/ settings / password中的渲染/设计/注册/编辑
To do that put this your view eg /settings/password 要做到这一点,请将您的视图设置为/ settings / password
<%= render :template => 'devise/registrations/edit' %>
and This in SettingsHelper 这在SettingsHelper中
def resource_name
:user
end
def resource
@resource = current_user || User.new
end
def devise_mapping
@devise_mapping ||= Devise.mappings[:user]
end
def devise_error_messages!
return "" if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
sentence = I18n.t("errors.messages.not_saved",
:count => resource.errors.count,
:resource => resource_name)
html = <<-HTML
<div id='error'>
<h2>{sentence}<h2>
<p>#{messages}</p>
</div>
HTML
html.html_safe
end
You can do the following: 您可以执行以下操作:
#routes.rb
get 'settings/password' => 'users#password'
And then in your controller, create the action password: 然后在您的控制器中,创建操作密码:
#users_controller.rb
def password
redirect_to :edit
end
If you are using Rails 3, you can simply do this: 如果您使用的是Rails 3,则只需执行以下操作:
#routes.rb
get 'settings/password' => redirect('users/edit')
Maybe this is what you are after? 也许这就是你追求的?
#routes.rb
devise_for :users do
get 'settings/password' => 'devise/registrations#edit'
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.