Here is a simple solution.
class ApplicationController ... def formats=(values) values << :html if values == [:mobile] super(values) end ... end
It turns out that Rails (3.2.11) already adds: html fallback for requests with the format: js. Here's ActionView::LookupContext#formats=
# Override formats= to expand ["*/*"] values and automatically # add :html as fallback to :js. def formats=(values) if values values.concat(default_formats) if values.delete "*/*" values << :html if values == [:js] end super(values) end
So, you can override #formats=
yourself, and it may not be more crude and hacked than the existing Rails implementation.
source share