I have an iPhone version of my site, and for some reason none of the rjs works when viewing the iPhone version. This happens instead: ActionView::MissingTemplate (Missing template controller_name/ update.erb in view path app/views) The rjs works fine when viewing the site normally, and it worked when viewing the iPhone version prior to upgrading Rails to 2.3.2. Additional info: I have ''Mime::Type.register_alias "text/ html", :iphone'' in mime_types.rb and the respond_to block in the action is what''d you expect -- respond_to do |format| format.js end What could be the problem? Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
No one knows why this is happening? I created a new rails app from scratch, first uncommenting "Mime::Type.register_alias "text/ html", :iphone" in mime_types.rb. Then I put this in my application controller: -------- before_filter :adjust_for_iphone def adjust_for_iphone request.format = :iphone if request.env[''HTTP_USER_AGENT''][/(Mobile \/.+Safari)/] end -------- I created an index controller, with an index and test action (index.html.erb, index.iphone.erb, test.js.rjs), and put a remote link in the index action to call test. Without any respond_to block in the test action, I get this: -------- ActionView::MissingTemplate (Missing template index/test.erb in view path app/views) -------- When this block is added to the test action: -------- respond_to do |format| format.js format.iphone { render ''test.js.rjs'' } # also tried without this render block end -------- There are no errors whatsoever, however the rjs doesn''t get executed at all, even with Firebug showing the js in the response. Surely someone can help with this? On Apr 3, 4:01 pm, Andrew <luckyd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have an iPhone version of my site, and for some reason none of the > rjs works when viewing the iPhone version. This happens instead: > > ActionView::MissingTemplate (Missing template controller_name/ > update.erb in view path app/views) > > The rjs works fine when viewing the site normally, and it worked when > viewing the iPhone version prior to upgrading Rails to 2.3.2. > > Additional info: I have ''Mime::Type.register_alias "text/ > html", :iphone'' in mime_types.rb and the respond_to block in the > action is what''d you expect -- > > respond_to do |format| > format.js > end > > What could be the problem? Thanks.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Marnen Laibow-Koser
2009-Apr-17 16:13 UTC
Re: RJS not rendering correctly when mime-type is ''iphone''
Andrew wrote: [...]> There are no errors whatsoever, however the rjs doesn''t get executed > at all, even with Firebug showing the js in the response. Surely > someone can help with this?The problem would appear to be that you''ve got your iphone mime-type defined as text/html. This means that even though Rails is correctly processing the RJS file, it is telling the browser that the file is HTML, not JavaScript. You''ll need a separate type (iphone_js or something) defined as text/javascript. RJS is evil anyway. :) Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Thanks for the advice; it worked fine pre-2.3 though. I added "Mime::Type.register_alias "text/javascript", :iphonejs" to mime_types.rb and put "format.iphonejs" in the respond_to block, but now I get a 406 Not Acceptable error. Am I doing it wrong? On Apr 17, 9:13 am, Marnen Laibow-Koser <rails-mailing-l...@andreas- s.net> wrote:> Andrew wrote: > > [...] > > > There are no errors whatsoever, however the rjs doesn''t get executed > > at all, even with Firebug showing the js in the response. Surely > > someone can help with this? > > The problem would appear to be that you''ve got youriphonemime-type > defined as text/html. This means that even though Rails is correctly > processing the RJS file, it is telling the browser that the file is > HTML, not JavaScript. You''ll need a separate type (iphone_js or > something) defined as text/javascript. > > RJS is evil anyway. :) > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 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 -~----------~----~----~----~------~----~------~--~---
Marnen Laibow-Koser
2009-Apr-19 22:25 UTC
Re: RJS not rendering correctly when mime-type is ''iphone''
Andrew wrote:> Thanks for the advice; it worked fine pre-2.3 though.I''m not sure why this would ever have worked, but then again MIME type mapping is one of my weak spots in Rails.> I added > "Mime::Type.register_alias "text/javascript", :iphonejs" to > mime_types.rb and put "format.iphonejs" in the respond_to block, but > now I get a 406 Not Acceptable error.Did you restart the server? If I remember correctly, defined MIME types are only loaded at server startup.> Am I doing it wrong?You must be, since you''re not getting the right result. :D But I''m not sure where the problem is, if restarting the server doesn''t do the trick. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/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 -~----------~----~----~----~------~----~------~--~---
I made a new app and I started from scratch. After following the steps in my previous posts, I still get 406 errors. This is so strange; it seems like I''m the only one in the world having this problem with 2.3! Anything else I can do? On Apr 19, 3:25 pm, Marnen Laibow-Koser <rails-mailing-l...@andreas- s.net> wrote:> Andrew wrote: > > Thanks for the advice; it worked fine pre-2.3 though. > > I''m not sure why this would ever have worked, but then again MIME type > mapping is one of my weak spots in Rails. > > > I added > > "Mime::Type.register_alias "text/javascript", :iphonejs" to > > mime_types.rb and put "format.iphonejs" in the respond_to block, but > > now I get a 406 Not Acceptable error. > > Did you restart the server? If I remember correctly, defined MIME types > are only loaded at server startup. > > > Am I doing it wrong? > > You must be, since you''re not getting the right result. :D > > But I''m not sure where the problem is, if restarting the server doesn''t > do the trick. > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > Posted viahttp://www.ruby-forum.com/.
Marnen Laibow-Koser
2009-Apr-30 20:30 UTC
Re: RJS not rendering correctly when mime-type is ''iphone''
Andrew wrote:> I made a new app and I started from scratch. After following the steps > in my previous posts, I still get 406 errors.[...] Hmm. I forgot to ask: what''s the name of the RJS file? I should be something.iphonejs.rjs... Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
Yes, I have tried it with the file named something.iphonejs.rjs. On Apr 30, 1:30 pm, Marnen Laibow-Koser <rails-mailing-l...@andreas- s.net> wrote:> Andrew wrote: > > I made a new app and I started from scratch. After following the steps > > in my previous posts, I still get 406 errors. > > [...] > > Hmm. I forgot to ask: what''s the name of the RJS file? I should be > something.iphonejs.rjs... > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > Posted viahttp://www.ruby-forum.com/.