我使用Rails 3应用程序与devise
,simple form
和haml
宝石。另外我的应用程序支持几个语言环境我在我的主页上创建了简单链接:Rails 3 +设计 - 登录用户无法打开页面来更改密码
%p
= link_to "Change pass", edit_user_password_path
应用程序显示此链接适用于所有人(只是测试它)。但我建立了非登录用户可以打开此链接。但是,当登录用户打开此链接然后系统告诉:
You are already signed in.
我无法确定我做错了什么。
我的用户模型:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
# attr_accessible :title, :body
end
我的路线:
scope ":locale", locale: /#{I18n.available_locales.join("|")}/ do
devise_for :users, :skip => [:registrations]
root :to => 'pages#home'
end
match '*path', to: redirect("/#{I18n.default_locale}/%{path}"), constraints: lambda { |req| !req.path.starts_with? "/#{I18n.default_locale}/" }
match '', to: redirect("/#{I18n.default_locale}")
另外我评论几行视图/设计/共享/ _links.haml
- if devise_mapping.registerable? && controller_name != 'registrations'
/= link_to t(".sign_up_link"), new_registration_path(resource_name)
/%br/
由于我不想让用户注册并查看链接。
这很奇怪。我试图在我的视图中使用'edit_user_registration_path',但Rails生成'未定义的局部变量或方法'edit_user_registration_path'。 – ExiRe
您需要删除该路径的':skip => [:registrations]',或者使用Wiki文章提供的自定义策略。 – janders223
感谢您的通知!! – ExiRe