Weird response for controller.request.format.html? in Rails
Posted
by Tony
on Stack Overflow
See other posts from Stack Overflow
or by Tony
Published on 2009-10-01T20:29:09Z
Indexed on
2010/04/03
6:03 UTC
Read the original article
Hit count: 514
In my main controller, I have this:
class MainController < ApplicationController
before_filter do |controller|
logger.info "controller.request.format.html? = #{controller.request.format.html?}"
logger.info "controller.request.format.fbml? = #{controller.request.format.fbml?}"
controller.send :login_required if controller.request.format.html?
controller.send :facebook_auth_required if controller.request.format.fbml?
end
As expected, I get "true" for the ...fbml? line if a request comes from Facebook (my facebooker gem automatically sets the format). However, I get "5" for the ...html? line if the request comes from Facebook. Why would a method with a ? ever return a "5"? Isn't that against Rails conventions? Also, I think "5" is considered true so this might mess up my filters. Still looking into that...
Any ideas?
© Stack Overflow or respective owner