我在 /views/devise/registrations/edit.html.erb 中有这段代码
<b>Cancel my account</b>
<%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>.
这允许登录的用户删除他的帐户。现在我不希望一个 id=223 的用户拥有这个权限/链接。我怎样才能做到这一点 ?我不确定edit.html.erb文件中的以下代码是否有效(或者有更好的方法吗?)
编辑 - 好的,下面的代码正在工作,但如何通过控制器来做到这一点?
<% if current_user.id != 223 %>
<b>Cancel my account</b>
<%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>.
<% end %>