Rails - Display flash notice before running method -


i have method in controller index action, add_product_data, updates product data if title of first or last product nil. flash message display if title of first or last product nil, before add_product_data method called, user knows why request taking long.

what have:

def index   if params["rating_set_id"]     @products = product.find(:all, :joins => :rating_sets, :conditions => ["rating_set_id = ?", params["rating_set_id"]])     if @products.first.title.nil? && @products.last.title.nil?       redirect_to :back, :flash => { :notice => "updating missing product data..." }       fetchrec.add_product_data(@products)      end      @rating_set = ratingset.find(params["rating_set_id"])     @unique_dept = product.find_by_sql("select dept products dept <> '' group dept")   else     @products = product.all   end end 

as have set up, flash message displays after product data added , request made. how can display flash message when request made, , if add_product_data method needs called.

if have long-running request, can use async runner such sidekiq , return 202 (accepted) flash message. there no way in "standard" http/html show message before request completes.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -