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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:07:00+00:00 2026-06-18T03:07:00+00:00

I have a Ruby on Rails app that allows the user to login with

  • 0

I have a Ruby on Rails app that allows the user to login with their Facebook account. I want to be able to a list of users and their Facebook data. I have been able to accomplish this however I have to send a request for each user’s name and I want to do this as a batch operation. How would I be able to put this in my user model?

User Model

class User < ActiveRecord::Base
  attr_accessible :uid

  def facebook_name
    Koala::Facebook::API.new.get_object(uid)["name"].to_s
  end
end

Example of Inefficient code

users = Users.all

users.each do |user|
  puts user.facebook_name
end
  • 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-06-18T03:07:01+00:00Added an answer on June 18, 2026 at 3:07 am

    Use a background task (such as https://github.com/collectiveidea/delayed_job) to populate the data in the database.

    For example

    class User
     after_create :delayed_populate
    
     def populate_from_facebook
       self.facebook_name = Koala::Facebook::API.new.get_object(uid)["name"].to_s
     end
    
     def delayed_populate
       delay.populate_from_facebook
     end 
    end
    

    Then, once you’ve done that, it’s just a regular model database to iterate through them, as the fields will be cached in your DB. You really don’t want to be making HTTP api requests during responding to another HTTP request.

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

Sidebar

Related Questions

I have Ruby on Rails site. Users are allowed to login using their Facebook
I have built a Ruby on Rails app that allows users to track workouts.
I have built a ruby on rails app that allows for users to track
I have a Rails app that allows users to build up a network structure
Have a Ruby on Rails app that uses BCrypt to hash passwords, the User
Some of the users of our Ruby on Rails app have complained that page
I have built a Ruby on Rails (2.3.8) application that allows users to track
We have an Ruby on Rail app that allows the user to save a
I have a Ruby on Rails app that I've recently deployed to a remote
I have a ruby (1.9.3) on rails (3.1) app where: app/models/list.rb class List <

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.