What does .:format mean in rake routes

前端 未结 2 1317
野性不改
野性不改 2021-01-31 16:36

I type rake routes and I get a bunch of urls like this - /articles/:id(.:format)

My question is - what does the .:format mean? It is not clear

2条回答
  •  臣服心动
    2021-01-31 17:19

    .:format matches a mime type.

    For instance if you send a request looking for index.html the format catches 'html' as :format.

    Then in your controller it will get processed by something like

    respond_to do |format|
      format.html { #do something like redirect in here }
    end
    

提交回复
热议问题