Based on several tutorials online, my rails app uses a :mobile format to render pages optimized for mobile devices.
So for some actions, I have a *.mobile.erb file, in addition to the *.html.erb file.
But what if I want to disallow certain actions on the mobile site?
For example, for a particular resource, you can do Index and Show, but not Edit or New, when you’re mobile.
What’s the best way to do this? Currently, I just don’t have edit.mobile.erb or new.mobile.erb, but that just shows a “Template Missing” error – not very graceful.
Any suggestions?
You could try accessing params[:format] to check if the action is valid for a particular format. If not, you could redirect or show a custom error page, or whatever else it is you want to do to gracefully disallow an action.