Skip to main content

User Referral Program From Scratch Discussion

General • Asked by Chris Oliver

Just the thing I was needed for a current project, as usual, perfect timing Chris !

I love when that happens!


TIP: If any of you are using validations in devise, before_create in the user.rb file may not work, and you will get an error.

Therefore, try changing that line in user.rb to before_validation and you may find that it works.

Quick note here: you'll want to add a conditional check if self.referral_code.nil? to the make sure you don't re-generate and overwrite the existing referral code in the event a user needs to use the Forgot Password function.

You're correct @Monroe...I was getting an error with before_create claiming that the referral code already existed

Hi Charlie, so if someone clicks 'forgot password', that's going to have an effect on the referral code? Can you elaborate?

Hi Taylor, glad I was able to help!


Nice one! Want to expand on this one, but a great start - thanks.


I tried using it with omniauth : facebook and google it doesn't save the referred_by_id, any solution ?


When I try to create the new app using the jumpstart template, I land on this error

insert  config/webpack/environment.js
The file /Users/ijsemerene/Documents/GitHub/jumpstart/referral_app/config/webpack/environment.js does not appear to exist

Any ideas on how to address it?

Hey Ignacio,

If you look through the logs above, did it fail when installing webpacker?

Yup, looks like it's failing there first

What's the error?


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 20,000+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.