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 6887679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:54:51+00:00 2026-05-27T05:54:51+00:00

I have an application running in Heroku. The app has a User model with

  • 0

I have an application running in Heroku. The app has a User model with email, password, a few other columns. I recently added more columns to the database locally, including a random token column that is a unique token for each user. When a user is created, the following code is run in the user model:

before_create :set_referer_url

...

private 

def set_referer_url
  begin
    self.referer_url = rand(36**8).to_s(36)
  end while User.exists?(:referer_url => self.referer_url)
end

For any new user that is created, they will have this unique token. However, older users will not. I wanted to push this migration (with the new database column) to heroku. How do I add this token for users created before this new column was added. I’ve heard a lot about rake, but any help would be greatly appreciated.

As an aside, I tried to add a token for a test user locally from the rails console by doing the following:

User.find_by_email('xyz').set_referer_url

This, however, resulted in a NoMethod Error: private method. How can I invoke private methods in rake? What would the entire rake procedure look like in order to set up old users with the populated new token column?

  • 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-27T05:54:51+00:00Added an answer on May 27, 2026 at 5:54 am

    To call a private method from outside of the object, use send:

    User.find_by_email('xyz').send(:set_referer_url)
    

    It’s generally bad practice to do this as a matter of course, as private methods are private for a reason. But for a one-off backfill of existing data as part of a migration I think it’s OK.

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

Sidebar

Related Questions

I have an application running in tomcat that has a bunch of configuration files
I have a rails app running on Heroku. I am using paperclip for some
I have a Rails 3 app running on Heroku and I also have a
I have an application up and running on Heroku with Express.js on Node.js with
I have a Sinatra application running on Heroku which makes use of Dalli to
I have an application running only on Windows and a batch file that launches
I have an application running on multiple IIS servers that need to parse a
I have an application running on Websphere Application Server 6.0 and it crashes nearly
I have an application running under WebLogic that is using standard forms authentication. The
We have an application running on a loadbalanced environment, let say webserver A and

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.