Rails - Doesn't block HTTP requests?

I want to display some Amazon products downloaded through Ajax.

I call the method below using Ajax, but the request takes a couple of seconds.

@items = []
@shows.shuffle.first(5).each do |show|
    req = AmazonProduct["us"]
    req.configure do |c|
      c.key = "###"
      c.secret = "###"
      c.tag = "###"
    end
    req << { :operation => 'ItemSearch',
             :search_index => params[:product_type],
             :response_group => %w{ItemAttributes Images},
             :keywords => show.name,
             :sort => "" }
    resp = req.get
    @items << resp.find('Item').shuffle.first
end

I did not notice that this action blocks the server. I tried to open the site in a different tab. This tab will not start loading until the first tab with an Ajax call completes.

How can I solve this problem?


Setup:

Ubuntu 10.10
Rails 3.1.1
Ruby 1.9.2
Gem: https://github.com/hakanensari/amazon_product

+5
source share
2 answers

EDIT:

Just to clarify, it depends on the server that you use in your development environment, these are not rails.

WebRick ( http dev) . puma, unicorn, Phusion Passenger , ( ).

OLD :

, .

, , - synatra-synchrony, , .

ajax , ().

. , , .

, :

AJAX -> amazon-producs-sinatra-app.yourdomain.com 
0

, , Rails sever, Webrick.

, webrick ( ).

Rails sever, , Phusion Passenger, mongrel/thin servers, concurrency:)

+2

All Articles