Ok so Facebook sends an accepts header of
*/*
Since no specific format is requested, rails just goes down the respond_to block in order. If you list your js first in the respond_to block like below rails will respond to the facebook open crawler with JSON which will not work:
respond_to do |format|
format.js { render :json => @this.to_json }
format.html
end
Just switch the order so by default rails responds with HTML:
respond_to do |format|
format.html
format.js { render :json => @this.to_json }
end
I'm not sure why Facebook does not specify the format they are looking for... seems pretty idiotic to me. Hopefully this is helpful to somebody down the road.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…