我使用带有devise
,simple form
和haml
gems 的 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}")
我还在views/devise/shared/_links.haml中评论了几行
- if devise_mapping.registerable? && controller_name != 'registrations'
/ = link_to t(".sign_up_link"), new_registration_path(resource_name)
/ %br/
因为我不想让用户注册并查看链接。