Reputation: 24267
When I run rake routes
, I get something like this:
signin /signin(.:format) application#signin
What is the (.:format) in the middle?
Upvotes: 0
Views: 39
Reputation: 42048
It's an optional format. It matches URLs like:
/signin
/signin.html
/signin.json
This format can then be used in the controller. For example:
class UsersController < ApplicationController
def index
@users = User.all
respond_to do |format|
format.html # index.html.erb
format.xml { render xml: @users}
format.json { render json: @users}
end
end
end
This code snippet is from Action Controller Overview. See more details in the routing guide.
Upvotes: 3