steve.odom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Sep-01 21:37 UTC
respond_to strangeness
Hi, I''m in the process of RESTifying my site. Almost there and loving it. I started having this strange problem today. In my controller if I have something like.... def show @question = Question.find(2) end ....it displays my show.rhtml file with no problems. If if change it to this.... class QuestionsController def show @question = Question.find(2) respond_to do |type| type.html type.js type.xml { render :xml => @question.to_xml } end end ..then it starts throwing a "No rhtml, rxml, rjs or delegate template found for questions/show.rhtml" But it will successfully show questions/2.xml in xml format. I can get the html to work if I change the type.html line to: type.html { render :action => ''show''} My dev log doesn''t give me any clues. Any ideas? Thanks, Steve Odom --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Steve, You did define a response for a request in the xml format and you should be doing the same thing for the html request which you are doing in the second case by rendering the show view. Uma --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
steve.odom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Sep-01 22:19 UTC
Re: respond_to strangeness
I was under the impression that I didn''t have to do define a response like: type.html { render :action => ''show'' } that just "type.html" is enough as long as I have the show.rhtml file in my view. What is wierd is that "type.html" was working fine without render instructions until earlier today when I started focusing on building an xml view. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
steve.odom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> I was under the impression that I didn''t have to do define a response > like: > type.html { render :action => ''show'' } > > that just "type.html" is enough as long as I have the show.rhtml file > in my view. > > What is wierd is that "type.html" was working fine without render > instructions until earlier today when I started focusing on building an > xml view.Yes you are right, the default action is to call the render method. It still brings us to your initial issue though. So you currently have both the .rhtml as well as the .rxml views for the action I assume. and how do you send the xml request ? Try to remove the type.xml and see if it behaves the same way. I am not sure of any other particular reason though... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
steve.odom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Sep-01 23:33 UTC
Re: respond_to strangeness
> So you currently have both the .rhtml as well as the .rxml views for > the action I assume.yep, both are in my questions view directory> and how do you send the xml request ?I was just adding .xml to the url (ie localhost:3000/questions/56.xml )> Try to remove the type.xml and see if it behaves the same way.I tried that. As long as I have respond_to .... and no explicit render instructions next to type.html then I''ll get an error - despite the show.rhtml file being available.> I am not sure of any other particular reason though...It''s puzzling. thanks for your help. Steve --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Solved. It was my globalize-rails plugin that was screwing up the respond_to. On 9/1/06, steve.odom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <steve.odom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > > So you currently have both the .rhtml as well as the .rxml views for > > the action I assume. > yep, both are in my questions view directory > > > and how do you send the xml request ? > > I was just adding .xml to the url (ie localhost:3000/questions/56.xml ) > > > Try to remove the type.xml and see if it behaves the same way. > > I tried that. As long as I have respond_to .... and no explicit render > instructions next to type.html then I''ll get an error - despite the > show.rhtml file being available. > > > I am not sure of any other particular reason though... > > It''s puzzling. thanks for your help. > > Steve > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---