我的问题:我有一个rails应用程序,现在我看到生产日志和dev不同的计算机,这些东西加倍所有动作:
路线:
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
没有回调,设置(在“def index”之后放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 .....
是什么?
答案 0 :(得分:0)
问题在于gem rails_12factor
包含在所有ENV中,它进行了双重记录。 行动真的只做一次
现在我将 group :: production 添加到gem,并计划将webrick web服务器更改为prod中的其他服务器
感谢您的帮助