0
我的問題:我有一個Rails應用程序,現在我看到在生產日誌和DEV不同的計算機上,這東西雙所有操作:Rails應用程序使2個動作每1個請求
路線:
root "main_page#index"
resources :search, only: [:index]
日誌heroku上(生產)
2014-02-10T07:45:08.214686+00:00 app[web.1]: Started GET "/search?type=shortdata
&data=501" for 1.1.1.1 at 2014-02-10 07:45:08 +0000
2014-02-10T07:45:08.214734+00:00 app[web.1]: Started GET "/search?type=shortdata
&data=501" for 1.1.1.1 at 2014-02-10 07:45:08 +0000
2014-02-10T07:45:08.222497+00:00 heroku[router]: at=info method=GET path=/search
?type=shortdata&data=501 host=app.herokuapp.com request_id=4a0c2345-336
e-44fd-b33b-44caeb3bac90 fwd="1.1.1.1" dyno=web.1 connect=0ms service=13m
s status=304 bytes=0
2014-02-10T07:45:08.217106+00:00 app[web.1]: Processing by SearchController#inde
x as JSON
2014-02-10T07:45:08.217106+00:00 app[web.1]: Processing by SearchController#inde
x as JSON
2014-02-10T07:45:08.217106+00:00 app[web.1]: Parameters: {"type"=>"shortdata",
"data"=>"501"}
2014-02-10T07:45:08.217106+00:00 app[web.1]: Parameters: {"type"=>"shortdata",
"data"=>"501"}
2014-02-10T07:45:08.222806+00:00 app[web.1]: Completed 200 OK in 5ms (Views: 0.5
ms | ActiveRecord: 3.9ms)
2014-02-10T07:45:08.222806+00:00 app[web.1]: Completed 200 OK in 5ms (Views: 0.5
ms | ActiveRecord: 3.9ms)
控制器:
def index
data = params[:data]
type=params[:type]
if type==ShortDataType
if likeAZip?(data)
render(json:shortSearchByZip(data)) && return
else
render(json:shortSearchByCity(data)) && return
end
else
render json:nothing
end
end
沒有回調,設置(放置1日後 「高清指數」) - 它去記錄只有1次 - 結果:
Started GET "/search?type=shortdata&data=501" for 127.0.0.1 at 2014-02-10 18:54:
38 +1100
Started GET "/search?type=shortdata&data=501" for 127.0.0.1 at 2014-02-10 18:54:
38 +1100
Processing by SearchController#index as JSON
Processing by SearchController#index as JSON
Parameters: {"type"=>"shortdata", "data"=>"501"}
Parameters: {"type"=>"shortdata", "data"=>"501"}
1
(2.0ms) select .....
是什麼呢?
可以添加你的HTML。 erb文件和你的javascript,如果你的搜索是通過ajax完成的?我想過去有類似的問題,這不是由於服務器代碼造成的,而是由瀏覽器造成的。 – franchez
當Ajax調用鏈接到onchange等事件時,我已經看到類似這樣的事情。那些有時會比你想像的更頻繁地點燃。 –