How to force the routing format being the request one

I am trying to test the mobile way … using mobile_fu and adding
the :mobile format
most of my test code is running adding :format => :mobile when
necessary, but I wonder how when a controller respond to the :mobile
format, the routing can use the request format

In this test case ( contact form) , when the request is coming from a
mobile, redirect_to new_contact_url is still using :html

thanks for feedback

respond_to :html, :mobile, :tablet

def new
@contact =

def create
destination = Rails.configuration.contact_address
@contact =
I18n.t(“mail_form.contact_form_subject”), destination: destination,
name: params[:contact_form][:name], email: params[:contact_form]
[:email], message: params[:contact_form][:message])
flash[:notice] = t(:message_send)
@contact =
redirect_to new_contact_url
render :new

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs