Hi Gurus, how do I include a partial in my main layout? In views/layouts/application.html.erb I have <code> ... <%= render :partial => ''navbar_tabs'' %> ... </code> No matter where I put _navbar_tabs.html.erb (or renamed it to _navbar_tabs.erb in desperation) I get the error Showing app/views/layouts/application.html.erb where line #20 raised: Missing template messages/_navbar_tabs.erb in view path app/views Can you help? TIA, Craig
Try giving the whole path in render like this: <%= render :partial => ''/messages/navbar_tabs'' %> # if your partial is in messages directory. Let us know if this does not work. Thanks, Abhinav -- अभिनव http://twitter.com/abhinav On Tue, Sep 8, 2009 at 4:54 PM, Dudebot <craignied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi Gurus, how do I include a partial in my main layout? > > In views/layouts/application.html.erb I have > > <code> > ... > <%= render :partial => ''navbar_tabs'' %> > ... > </code> > No matter where I put _navbar_tabs.html.erb (or renamed it to > _navbar_tabs.erb in desperation) I get the error > > > Showing app/views/layouts/application.html.erb where line #20 raised: > > Missing template messages/_navbar_tabs.erb in view path app/views > > Can you help? > > TIA, > Craig > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks-- <%= render :partial => ''layouts/navbar_tabs'' %> works. Seems kind of ugly, though--even in layouts, shouldn''t a form look in its own directory for a partial? Anyway, thanks! On Sep 8, 7:23 am, Abhinav Saxena <abhinav...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Try giving the whole path in render like this: > > <%= render :partial => ''/messages/navbar_tabs'' %> # if your partial is in > messages directory. > > Let us know if this does not work. > > Thanks, > Abhinav > > -- > अभिनवhttp://twitter.com/abhinav > > On Tue, Sep 8, 2009 at 4:54 PM, Dudebot <craign...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi Gurus, how do I include a partial in my main layout? > > > In views/layouts/application.html.erb I have > > > <code> > > ... > > <%= render :partial => ''navbar_tabs'' %> > > ... > > </code> > > No matter where I put _navbar_tabs.html.erb (or renamed it to > > _navbar_tabs.erb in desperation) I get the error > > > Showing app/views/layouts/application.html.erb where line #20 raised: > > > Missing template messages/_navbar_tabs.erb in view path app/views > > > Can you help? > > > TIA, > > Craig
Seems surprising to me as well. Thanks, Abhinav -- अभिनव http://twitter.com/abhinav On Tue, Sep 8, 2009 at 7:00 PM, Dudebot <craignied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Thanks-- > > <%= render :partial => ''layouts/navbar_tabs'' %> > > works. Seems kind of ugly, though--even in layouts, shouldn''t a form > look in its own directory for a partial? > > Anyway, thanks! > > On Sep 8, 7:23 am, Abhinav Saxena <abhinav...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Try giving the whole path in render like this: > > > > <%= render :partial => ''/messages/navbar_tabs'' %> # if your partial is in > > messages directory. > > > > Let us know if this does not work. > > > > Thanks, > > Abhinav > > > > -- > > अभिनवhttp://twitter.com/abhinav > > > > On Tue, Sep 8, 2009 at 4:54 PM, Dudebot <craign...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi Gurus, how do I include a partial in my main layout? > > > > > In views/layouts/application.html.erb I have > > > > > <code> > > > ... > > > <%= render :partial => ''navbar_tabs'' %> > > > ... > > > </code> > > > No matter where I put _navbar_tabs.html.erb (or renamed it to > > > _navbar_tabs.erb in desperation) I get the error > > > > > Showing app/views/layouts/application.html.erb where line #20 raised: > > > > > Missing template messages/_navbar_tabs.erb in view path app/views > > > > > Can you help? > > > > > TIA, > > > Craig > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
2009/9/8 Dudebot <craignied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > Hi Gurus, how do I include a partial in my main layout? > > In views/layouts/application.html.erb I have > > <code> > ... > <%= render :partial => ''navbar_tabs'' %> > ... > </code> > No matter where I put _navbar_tabs.html.erb (or renamed it to > _navbar_tabs.erb in desperation) I get the error > > > Showing app/views/layouts/application.html.erb where line #20 raised: > > Missing template messages/_navbar_tabs.erb in view path app/views >What happens if you name it _navbar_tabs.html.erb and put in in views/messages? Colin
On Tue, Sep 8, 2009 at 6:30 AM, Dudebot <craignied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Thanks-- > > <%= render :partial => ''layouts/navbar_tabs'' %> > > works. Seems kind of ugly, though--even in layouts, shouldn''t a form > look in its own directory for a partial? > >If you''re using the partial in the layout, it means the partial will be displayed on every page of the site by default. Is this the case? -Conrad> Anyway, thanks! > > On Sep 8, 7:23 am, Abhinav Saxena <abhinav...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Try giving the whole path in render like this: > > > > <%= render :partial => ''/messages/navbar_tabs'' %> # if your partial is in > > messages directory. > > > > Let us know if this does not work. > > > > Thanks, > > Abhinav > > > > -- > > अभिनवhttp://twitter.com/abhinav > > > > On Tue, Sep 8, 2009 at 4:54 PM, Dudebot <craign...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi Gurus, how do I include a partial in my main layout? > > > > > In views/layouts/application.html.erb I have > > > > > <code> > > > ... > > > <%= render :partial => ''navbar_tabs'' %> > > > ... > > > </code> > > > No matter where I put _navbar_tabs.html.erb (or renamed it to > > > _navbar_tabs.erb in desperation) I get the error > > > > > Showing app/views/layouts/application.html.erb where line #20 raised: > > > > > Missing template messages/_navbar_tabs.erb in view path app/views > > > > > Can you help? > > > > > TIA, > > > Craig > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
By convention, any partials that are loaded by "application.html.erb" are loaded by all controllers in the application. That being the case, when rendering app->messages->index: The app...erb line will read "<%= render :partial => ''layouts/ app_wide_partial'' %> The partial will be found in views/layouts/ _app_wide_partial.html.erb When the line in app...erb is reached that reads "<%= yield %>" The file "views/messages/index.html.erb" is rendered And you have a file views/layouts/application.html.erb that calls "<%= render :partial => ''navbar_tabs'' %>" Rails will look for the partial named: views/messages/ _navbar_tabs.html.erb It is customary practice to follow the convention "... :partial => ''directory/partial'' %>" just so there is no confusion. Thus, if you had additional message related tabs, you would include in views/ messages/index.html.erb: <%= render :partial => ''messages/ msg_navbar_tabs'' %> On Sep 8, 10:55 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> 2009/9/8 Dudebot <craign...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > > > > > Hi Gurus, how do I include a partial in my main layout? > > > In views/layouts/application.html.erb I have > > > <code> > > ... > > <%= render :partial => ''navbar_tabs'' %> > > ... > > </code> > > No matter where I put _navbar_tabs.html.erb (or renamed it to > > _navbar_tabs.erb in desperation) I get the error > > > Showing app/views/layouts/application.html.erb where line #20 raised: > > > Missing template messages/_navbar_tabs.erb in view path app/views > > What happens if you name it _navbar_tabs.html.erb and put in in views/messages? > > Colin
> works. Seems kind of ugly, though--even in layouts, shouldn''t a form > look in its own directory for a partial?It does, you''re just misunderstanding what "its own directory" refers to. Your form is not a part of "layouts," it''s a part of the controller rendering it. On Sep 8, 6:30 am, Dudebot <craign...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks-- > > <%= render :partial => ''layouts/navbar_tabs'' %> > > works. Seems kind of ugly, though--even in layouts, shouldn''t a form > look in its own directory for a partial? > > Anyway, thanks! > > On Sep 8, 7:23 am, Abhinav Saxena <abhinav...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Try giving the whole path in render like this: > > > <%= render :partial => ''/messages/navbar_tabs'' %> # if your partial is in > > messages directory. > > > Let us know if this does not work. > > > Thanks, > > Abhinav > > > -- > > अभिनवhttp://twitter.com/abhinav > > > On Tue, Sep 8, 2009 at 4:54 PM, Dudebot <craign...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi Gurus, how do I include a partial in my main layout? > > > > In views/layouts/application.html.erb I have > > > > <code> > > > ... > > > <%= render :partial => ''navbar_tabs'' %> > > > ... > > > </code> > > > No matter where I put _navbar_tabs.html.erb (or renamed it to > > > _navbar_tabs.erb in desperation) I get the error > > > > Showing app/views/layouts/application.html.erb where line #20 raised: > > > > Missing template messages/_navbar_tabs.erb in view path app/views > > > > Can you help? > > > > TIA, > > > Craig > >