Whenever a model is created in my application, an email is sent out to several people. The response to the model creation is JS, so there is a slight delay in updating the page because first all the emails are being sent then the JS view logic kicks in (i.e. there is a noticeable lag between the time the Create button is pushed and when the page updates itself).
Is there a way I can set up my controller so that the emails are sent AFTER the view is finished updating?
Here is what my Controller action basically looks like:
def create
@model = Model.new(params[:model])
@model.save
@followers.each do |f|
ModelMailer.some_email(f).deliver
end
respond_to do |format|
format.js { render :layout => false }
end
end