title: Hide & Show password field in view, with Omniauth and facebook login
body: <p>Good evening all!</p>
  
  <p>I'm having a bit of an issue, which i'll explain after some context!</p>
  
  <p>Gems involved:
  Devise, Omniauth, Omniauth-facebook</p>
  
  <p>I've set up omniauth alongside devise, to allow users of my site to login/register via facebook, it works perfectly.
  Along side this I also have a regular sign up page in which users can enter a username, email and password to register to the website.</p>
  
  <p>The issue comes when a user wishes to edit their information once they are registered - via the Edit view. I want to hide the password fields for Facebook registered users (as they of course have no password), leaving only Name and Email (for now), but have the password fields show for Regular registered users so they can change their passwords.</p>
  
  <p>In the mean time I have managed to by-pass the "enter confirmation password" forced by devise, so Facebook users don't need to enter a confirmation password (as one doesn't exist) where regular users do. 
  Achieved by the following in user.rb: </p>
  
  <pre><code>def update_with_password(params, *options)
   if encrypted_password.blank?
   update_attributes(params, *options)
  else
   super
   end
  end
  </code></pre>
  
  <p>To solve my password problem, I have attempted adding the following to my user.rb: </p>
  
  <pre><code>   def password_required?
      (authentications.empty? || !password.blank?) &amp;&amp; super
     end
  </code></pre>
  
  <p>Followed by the following in my devise\registrations\edit.html.erb:</p>
  
  <pre><code>&lt;% if @user.password_required? %&gt;
    &lt;%= f.input :current_password, :hint =&gt; "We need your current password to confirm any changes", :required =&gt; false %&gt;
   &lt;h5&gt;Change your password?&lt;/h5&gt;
    &lt;%= f.input :password, :autocomplete =&gt; "off", :hint =&gt; "Enter a new password above,      leave Password blank if you do not wish to change it", :required =&gt; false %&gt;
    &lt;%= f.input :password_confirmation, :required =&gt; false %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>After following elements of this guide: <a href="http://www.orhancanceylan.com/rails-twitter-and-facebook-authentications-with-omniauth-and-devise/" rel="nofollow">http://www.orhancanceylan.com/rails-twitter-and-facebook-authentications-with-omniauth-and-devise/</a>.</p>
  
  <p>The password inputs are hidden by the above code, however it is hidden for both Facebook registered users and regular registered users, so I'm afraid I'm at a loss!</p>
  
  <p>Please let me know if there's anything else I should've posted to help narrow down the issue, and apologies if I have missed posting anything related.</p>
  
  <p>Thank you in advance :)</p>