Friday, April 22, 2011

[Rails] 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 :)

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate