This question is a follow up to my previous unanswered question: ActionView::MissingTemplate: Missing template (Trying to render nonexistent :mobile format )
Since doesn’t seem to be a Rails approach consensus with this, Is there any way that when accessing from a mobile device to render default :html when :mobile format is not available? (If a :mobile view is present should have priority over those who are not mobile formatted).
assume you got a
mobile_request?controller instance method to detect mobile requests, then you should be able to set format fallback chains:This should work but apparently it doesn’t completely.
https://github.com/rails/rails/issues/3855
If you have a mobile template, the format seems to get locked and it will not find a partial with only html.
Hopefully it will be fixed some way or other.
In the meantime you can put this <% controller.set_format_fallbacks %> in each template (ouch) or write your own resolver.
http://jkfill.com/2011/03/11/implementing-a-rails-3-view-resolver/
also look at:
Can a mobile mime type fall back to "html" in Rails?
Changing view formats in rails 3.1 (delivering mobile html formats, fallback on normal html)