I have some basic respond_to blocks that essentially look like this: respond_to do |format| format.iphone { render } format.mobile { render } end This is working great right now and I have it all over the place in my code. Kind of odd that there''s no format for just plain ol'' HTML right? Right. Since I''m not building a desktop browser version yet, I''m not terribly concerned about supporting desktop browsers, but I do want something that at least works. But here''s the problem: - the iphone version doesn''t work on all desktop browsers and won''t for the foreseeable future (yeah, so i went a little iphone crazy) - the mobile version''s MIME type is "application/vnd.wap.xhtml+xml" which won''t work on desktop browsers For now what I''d like to do is render the mobile version to desktop browsers but with a mime type of "text/html". Question is, what is the easiest way to accomplish this given a fair amount of existing respond to blocks and templates named with *.mobile.erb I''m tempted to just take the easy way out and change the mime type of mobile to "text/html", but am curious if there are any smarter alternatives. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 21, 2007, at 11:17 AM, nootch wrote:> > I have some basic respond_to blocks that essentially look like this: > > respond_to do |format| > format.iphone { render } > format.mobile { render } > end > > This is working great right now and I have it all over the place in my > code. Kind of odd that there''s no format for just plain ol'' HTML > right? Right. Since I''m not building a desktop browser version yet, > I''m not terribly concerned about supporting desktop browsers, but I do > want something that at least works. But here''s the problem: >Um. format.html? Rails assumes that format if there isn''t a different one explicitly requested. Peace, Phillip --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 21, 12:34 pm, Phillip Koebbe <phillipkoe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Um. format.html? Rails assumes that format if there isn''t a > different one explicitly requested.Good to know. But if I''m going to render the same template as another format, some changes will need to be made. But maybe it''s as simple as changing all templates named "*.mobile.erb" to "*.erb" so that format.html can find them. Or if that doesn''t work use a variation on the render call to force the html format to render the mobile template. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 21, 2007, at 12:16 PM, nootch wrote:> > On Dec 21, 12:34 pm, Phillip Koebbe <phillipkoe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Um. format.html? Rails assumes that format if there isn''t a >> different one explicitly requested. > > Good to know. But if I''m going to render the same template as another > format, some changes will need to be made. But maybe it''s as simple as > changing all templates named "*.mobile.erb" to "*.erb" so that > format.html can find them. Or if that doesn''t work use a variation on > the render call to force the html format to render the mobile > template.or use partials. Phillip --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> or use partials. > > PhillipGood idea. I ended up actually not using partials (since it would involve moving a bunch of files around). But this combo of methods seems to work: respond_to do |format| format.iphone { } format.mobile { } format.html { render :action => "theaction.mobile.erb" } end This almost just works, but rails doesn''t know how to find the mobile layout. So I did this: layout :force_to_mobile_layout def force_to_mobile_layout if @iphone # only trick part: since :iphone format is just an alias for text/html, we have to do our own check "application.iphone.erb" else "application.mobile.erb" end end --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---