Rails content negotiation explained
Explain the following snippet found in a Rails controller:
def index
@posts = Post.all
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @posts }
end
end
Useful link to Ruby procs, blocks and lambdas