Quantcast
Channel: Active questions tagged redis+ruby-on-rails - Stack Overflow
Viewing all articles
Browse latest Browse all 873

How to save a record using a background worker?

$
0
0

If I am saving a video file onto the server that is greater than 5mb. Should I create a background job for saving this file?

How should this be done? My video model has a title, description and attachment columns/fields. All fields are required.

In def create, instead of doing "if @video.save", I should do something like "if Resque.enqueue(Save, @video)"?

I am not exactly sure how this can be done, since passing an argument to Resque.enqueue() turns it into a hash. Second, with ""if Resque.enqueue(Save, @video)"", expects a true or false. However, Resque.enqueue can't return anything. Or am I wrong?

Button line is. What is the appropriate way to save a record using a background worker with resque + redis?

Ideally, I was thinking it should look something similar to:

def create  @video = Video.new(params[:video])  respond_to do |format|    if Resque.enqueue(Save)      ...    endendmodule Save  @queue = :save  def self.perform    video = Video.new(params[:video])    video.save    return true  endend

What are your thoughts?


Viewing all articles
Browse latest Browse all 873

Trending Articles