jeff b
2008-Jan-18 02:19 UTC
render doesn''t find an html.erb file when called from a xml/atom builder?
I''m trying to put together an atom feed. In trying to keep things DRY it seemed to make sense to render each item in the feed with the same html partial that we used to render it on our website. Unfortunately render doesn''t seem able to find the template. More specifically let''s say my controller has an action like this: def index @topics = Datasource.list respond_to do |wants| wants.html wants.atom do render :layout => false end end end And buried inside my index.atom.builder there is a call to render shared/topic like so: entry.content(render( :partial => ''/shared/topic'', :object => topic ), :type => ''html'') I was assuming this would find the file at shared/_topic.html.erb and render it appropriately. No luck though, it gives me the error: Couldn''t find template file for /shared/_topic in ["/Users/jjb/eng/app/ views"] If I specify the full filename for the template (/shared/ topic.html.erb) it finds it, but that template has nested "render :partial" calls without the ".html.erb" on the end so they fail with the same error mentioned above. Any help would be greatly appreciated. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg
2008-Jan-18 03:21 UTC
Re: render doesn''t find an html.erb file when called from a xml/atom builder?
Why not just change the file extension to something atom compliant (.atom.xml?) What''s in this partial that you want to render? On Jan 18, 2008 12:49 PM, jeff b <jeffrey.barrett-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''m trying to put together an atom feed. In trying to keep things DRY > it seemed to make sense to render each item in the feed with the same > html partial that we used to render it on our website. Unfortunately > render doesn''t seem able to find the template. > > More specifically let''s say my controller has an action like this: > > def index > @topics = Datasource.list > respond_to do |wants| > wants.html > wants.atom do > render :layout => false > end > end > end > > And buried inside my index.atom.builder there is a call to render > shared/topic like so: > > entry.content(render( :partial => ''/shared/topic'', :object => > topic ), :type => ''html'') > > I was assuming this would find the file at shared/_topic.html.erb and > render it appropriately. No luck though, it gives me the error: > > Couldn''t find template file for /shared/_topic in ["/Users/jjb/eng/app/ > views"] > > If I specify the full filename for the template (/shared/ > topic.html.erb) it finds it, but that template has nested > "render :partial" calls without the ".html.erb" on the end so they > fail with the same error mentioned above. > > Any help would be greatly appreciated. > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
jeff b
2008-Jan-18 07:12 UTC
Re: render doesn''t find an html.erb file when called from a xml/atom builder?
The partial I want to render is a .html.erb and is used elsewhere on the site for traditional web-browser content. I sort of assumed that changing it to .atom.xml might make it work for the atom feed, but likewise break for traditional web-browser content for the same reason... On Jan 17, 7:21 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Why not just change the file extension to something atom compliant > (.atom.xml?) What''s in this partial that you want to render? > > On Jan 18, 2008 12:49 PM, jeff b <jeffrey.barr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > I''m trying to put together an atom feed. In trying to keep things DRY > > it seemed to make sense to render each item in the feed with the same > > html partial that we used to render it on our website. Unfortunately > > render doesn''t seem able to find the template. > > > More specifically let''s say my controller has an action like this: > > > def index > > @topics = Datasource.list > > respond_to do |wants| > > wants.html > > wants.atom do > > render :layout => false > > end > > end > > end > > > And buried inside my index.atom.builder there is a call to render > > shared/topic like so: > > > entry.content(render( :partial => ''/shared/topic'', :object => > > topic ), :type => ''html'') > > > I was assuming this would find the file at shared/_topic.html.erb and > > render it appropriately. No luck though, it gives me the error: > > > Couldn''t find template file for /shared/_topic in ["/Users/jjb/eng/app/ > > views"] > > > If I specify the full filename for the template (/shared/ > > topic.html.erb) it finds it, but that template has nested > > "render :partial" calls without the ".html.erb" on the end so they > > fail with the same error mentioned above. > > > Any help would be greatly appreciated. > > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Keynan Pratt
2008-Jan-18 07:33 UTC
Re: render doesn''t find an html.erb file when called from a
sounds like a bug. Have your reported it on Rails Trac? -- 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 -~----------~----~----~----~------~----~------~--~---
Not yet. I was able to get it to work as expected. In the index action changing this: render :layout => false To this: render :template => ''topic/index.atom.builder'', :layout => false Seemed to do the trick. Does this sound like a bug? On Jan 17, 11:33 pm, Keynan Pratt <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> sounds like a bug. Have your reported it on Rails Trac? > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I found a solution for this - at least in my situation. It seems that making the render call from within a respond_to was causing the problem. By moving it to a seperate action and not in respond_to I worked around this strangeness. On Jan 17, 11:33 pm, Keynan Pratt <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> sounds like a bug. Have your reported it on Rails Trac? > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---