Rails 3 アプリケーションをdevise
、simple form
およびhaml
gems で使用しています。また、私のアプリケーションはいくつかのロケールをサポートしています。ホームページに簡単なリンクを作成しました:
%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/
ユーザーが登録してリンクを表示できるようにしたくないためです。