我注意到在 中Rails 3.2.2
,所有动作都以*/*
格式处理。所以问题是:什么意思*/*
?以及为什么默认调用它(每次)?
因为一个动作有两个处理:
Started GET "/" for 127.0.0.1 at 2012-07-07 22:50:22 +0200
Processing by MainController#index as HTML
Started GET "/" for 127.0.0.1 at 2012-07-07 22:50:22 +0200
Processing by MainController#index as */*
我试图设置:
respond_to :html
def index
@posts = Post.all
respond_with(@posts)
end
但同样的问题仍然存在。
刚刚创建了基于Rails 3.2.6
. 用Thin 1.4.1
和测试Webrick
。同样的问题:
=> Booting Thin
=> Rails 3.2.6 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
>> Thin web server (v1.4.1 codename Chromeo)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop
Started GET "/mains" for 127.0.0.1 at 2012-07-09 10:53:55 +0200
Connecting to database specified by database.yml
Processing by MainsController#index as HTML
Main Load (0.1ms) SELECT `mains`.* FROM `mains`
Rendered mains/index.html.erb within layouts/application (2.7ms)
Completed 200 OK in 97ms (Views: 51.6ms | ActiveRecord: 1.3ms)
Started GET "/mains" for 127.0.0.1 at 2012-07-09 10:53:55 +0200
Processing by MainsController#index as */*
Main Load (0.1ms) SELECT `mains`.* FROM `mains`
Rendered mains/index.html.erb within layouts/application (0.5ms)
Completed 200 OK in 10ms (Views: 8.6ms | ActiveRecord: 0.1ms)