Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5949435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:14:58+00:00 2026-05-22T17:14:58+00:00

I am using Devise for my authentication. If a hashed_password isn’t set, Rails/Devise’s validations

  • 0

I am using Devise for my authentication. If a hashed_password isn’t set, Rails/Devise’s validations will require a password to be set, as well as the password_confirmation.

When I invite new users, I obviously don’t want to set their password, so when I create the invitation in my system, it fails because user.password is blank.

I can set a temporary hashed_password on the user, but when they enter their own password, the validation checks for :password and :password_confirmation will not happen because hashed_password is set, which is a real problem.

Is there any way to tell Rails that I want to run all the validations except for the ones associated with :password?

I know Rails has :if conditions, which might fix my problem, but Devise declares the :password validation on my behalf, so that essentially is hidden.

How can I get the desired result here?, hopefully in a way that is not a hack.

My current hypothetical solution that is somewhat messy: The only thing I can think of is to create a new Invitation model that is not the User model, and use the Invitation model for the form. When the invitation is submitted I can validate that Invitation and copy over all the values to the new User model. I can save that User without any validations at all.

That’s the best solution I dreamed up.

It seems like my solution will be a lot more work than saying something simple like:

user.save(validations => {:except => :password})

EDIT: I have found one part of the solution, but I am still having problems. In our user model, we can override a Devise method to prevent the validation of the password for invitations with this bit of code:

#protected
def password_required?
  !is_invited && super
end

The is_invited attribute is just a column I added to the users table/model.

However, there is one gotcha here. When a user accepts an invitation and they arrive to the form where they need to set their password/password_confirmation, valid? will always return true.

This one has me deeply perplexed. I don’t see how requires_password? and valid? can be true at the same time. If it requires the password, it should do a validation check and cause the validations to fail.

I’m starting to hate Devise – or just the idea of using gems to build parts of your application in a blackbox. I think the real solution probably is to rip out Devise and just do it all from scratch. That way your app has total control of how all of this works 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:14:59+00:00Added an answer on May 22, 2026 at 5:14 pm

    I recently started using this great devise add-on: devise_invitable

    It’s commonly used so users (or any model) can invite other users to join.

    But I adapt it for manually (via an admin panel) invite new potential users to my app.

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Devise for authentication in my Rails app. I'd like to eager load
I'm trying to get some basic authentication/authorization with devise/cancan with Rails. Rather than using
I'm trying to layout a Rails app using Devise for authentication. I'd like to
I'm using the devise authentication plugin under rails 3. At the moment, I have
I'm using the devise authentication plugin under rails 3. At the moment, I have
I have a Rails 3 application using Devise for authentication. In addition to the
I have an app that is using devise for authentication. Rails 3 on ruby
I am building a rails application using devise for authentication - including :confirmable functionality.
I have a rails 3 app that is currently using Devise for authentication. I
I'm using devise for authentication. How can I set the sign-in scope? For example,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.