I use Rails 3 application with devise, simple form and haml gems. Also my application supports few locales. I created simple link on my home page:
%p
= link_to "Change pass", edit_user_password_path
App shows this link for everyone (just to test it). But i founded that non log-in user can open this link. But when log-in user opens this link then system tells that:
You are already signed in.
I can’t figure what i’m doing wrong.
My User model:
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
My routes:
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}")
Also i commented few lines in views/devise/shared/_links.haml
- if devise_mapping.registerable? && controller_name != 'registrations'
/ = link_to t(".sign_up_link"), new_registration_path(resource_name)
/ %br/
Because i don’t want to allow users to register and see the link.
edit_user_password_pathis used by thepassword_controllerin Devise for when a user needs to reset their password. I think what you are looking for is theedit_user_registration_path. This will take the user to edit action of theregistrations_controllerwhere they can modify their email address and password. This is default Devise behavior.If you would like to provide something a little more custom, you can read a tutorial on the Devise Wiki on how to provide custom password change functionality.
Also take note, that when a user follows
edit_user_registration_paththere is an option for them to cancel their account that you may want to remove from the view, or use the custom approach to avoid this unwanted functionality.