Changing format (for respond_to)

So in my action I have:

  • respond_to do |format|
  • format.html
  • format.iphone
  • end

Now I can access action.html and action.iphone, however how would I make
it default to the iPhone view if the user agent is an iPhone. I’m pretty
tired so forgive me for being brief or perhaps missing something
obvious. I tried having the code below as a before_filter, but that
didn’t work.

  • if request.user_agent =~ /iPhone/
  • params[:format] = ‘iphone’
  • end

Anyway, thanks for your time :slight_smile:

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