Created
January 7, 2011 22:11
-
-
Save amrnt/770205 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%h2 | |
Edit #{resource_name.to_s.humanize} | |
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| | |
= devise_error_messages! | |
%p | |
= f.label :full_name | |
%br | |
= f.text_field :full_name | |
%p | |
= f.label :username | |
%br | |
= f.text_field :username | |
%p | |
= f.label :email | |
%br | |
= f.text_field :email | |
%p | |
= f.label :password | |
%i (leave blank if you don't want to change it) | |
%br | |
= f.password_field :password | |
%p | |
= f.label :password_confirmation | |
%br | |
= f.password_field :password_confirmation | |
-if @user.password_required? | |
%p | |
= f.label :current_password | |
%i (we need your current password to confirm your changes) | |
%br | |
= f.password_field :current_password | |
%p= f.submit "Update" | |
%h3 Cancel my account | |
%p | |
Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete}. | |
= link_to "Back", :back |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%h2 Sign up | |
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| | |
= devise_error_messages! | |
%p | |
= f.label :email | |
%br | |
= f.text_field :email | |
-if @user.password_required? | |
%p | |
= f.label :password | |
%br | |
= f.password_field :password | |
%p | |
= f.label :password_confirmation | |
%br | |
= f.password_field :password_confirmation | |
%p= f.submit "Sign up" | |
= render :partial => "devise/shared/links" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sign up with Twitter [works] | |
# redirect to /users/sign_up [works] | |
# it requires email [works] | |
# later, I | |
# I can update profile without a password [work, after adding 'update_with_password' method] | |
# I can add password (Password, Password confirmation) [works] | |
# After added password -> [current_password field should be required and visible) -> | |
# I should fill the current password in (current_password) field, to be able to update the profile | |
Class User | |
. | |
. | |
. | |
. | |
def update_with_password(params={}) | |
if params[:password].blank? | |
params.delete(:password) | |
params.delete(:password_confirmation) if params[:password_confirmation].blank? | |
end | |
update_attributes(params) | |
end | |
def password_required? | |
(authentications.empty? || !password.blank?) && super | |
end | |
. | |
. | |
. | |
. | |
. | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment