devise_invitable icon indicating copy to clipboard operation
devise_invitable copied to clipboard

"Password can't be blank" error

Open TatianaTyu opened this issue 15 years ago • 9 comments

Hi Sergio, I think I've found a small bug.

devise_invitable (0.5.6) devise (1.4.9) rails (3.1.1)

This line of code: u = User.invite!({:email => email}, inviter) does not set :invitation_token attribute (in earlier gem versions it did), which results in (u.valid? == false) with "Password can't be blank" error (because u.invitation_token == nil). But if I then do: u.invite! u.invitation_token is set, and everything is fine.

So in my code I had to fix it like this: u = User.invite!({:email => email}, inviter) u.invite! unless u.valid? # fix "Password can't be blank" issue.

This is just FYI, does not block me, you may close it if isn't reproduced on newer gem versions. Thank you very much for this gem!

TatianaTyu avatar Nov 21 '11 13:11 TatianaTyu

Do you have enabled validate_on_invite?

scambra avatar Nov 21 '11 14:11 scambra

Do you have enabled validate_on_invite? Probably bug is fixed in 0.5.7

scambra avatar Nov 21 '11 14:11 scambra

Yes: #devise.rb config.validate_on_invite = true

OK I will try 0.5.7. Thank you!

TatianaTyu avatar Nov 21 '11 15:11 TatianaTyu

I simply overrode password_required? - in my model- if indeed this is the same problem

def password_required? if new_record? false else !persisted? || !password.nil? || !password_confirmation.nil? end end

feralbob avatar Nov 26 '11 02:11 feralbob

@feralbob which version?

scambra avatar Nov 28 '11 10:11 scambra

@scambra - Should be 0.6.0

feralbob avatar Nov 28 '11 12:11 feralbob

Still reproduced in 0.6.0 .

TatianaTyu avatar Dec 25 '11 18:12 TatianaTyu

I submitted a pull request for this issue, but I'm going to redo per @scambra's request. Check it out and see if it helps you: https://github.com/scambra/devise_invitable/pull/152

djhopper01 avatar Dec 27 '11 03:12 djhopper01

It should be fixed with 842ee65 which fixed #152

scambra avatar Jan 31 '12 09:01 scambra