So I am creating new records for a model in the background using
resque (rails app). After the job runs, the new records are not
automatically indexed. If on the front end, I go and edit one of the
new records, then all of the records are then indexed.
What I am looking to do is have the records indexed when they are
added during the background task (so I don't have to do the front end
edit)
Here is the code
background task (upload_data.rb)
class UploadData
@queue = :events_queue
def self.perform(event_id)
event = Event.find(event_id)
CSV.parse($redis.get(
event.id)) do |row|
create_friends = event.friends.create(
:first_name => row[0],
:last_name => row[1],
:email => row[2]
etc.
The Friend model is the model that I want to index.
Any help would be greatly appreciated! Thanks!