Hi, im not sure if i am on the right path here, so i figured i would ask. Basically, all of my pages have the same header and footer, and i was wondering if there was some way i could reference this from the rhtml file? from what i have read on partial and template rendering, this is done in the controller, but in my case, the header and footer are static, so there is no logic. Basically, I am just trying to minimize the number of places i need to edit in case i make a change to my header or footer (i.e. if i add a link, i would really like to just update 1 file, rather than do it in all of my views). Is this possible? thanks! -- View this message in context: http://www.nabble.com/newbie-question-about-rendering-partials-and-rhtml-tf3692733.html#a10324965 Sent from the RubyOnRails Users mailing list archive at Nabble.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 -~----------~----~----~----~------~----~------~--~---
Dave Goodchild
2007-May-04 17:18 UTC
Re: newbie question about rendering partials and rhtml
Have a look at layouts, that is precisely what they are for. For example, if you create an html skeleton, call it application.rhtml and place it in the layouts folder (in views/), the app will call it by default. In the area where you want the controller-generated output to go, simply place this call: <% yield %> and the magic will take place. On 5/4/07, gmoniey <gmoniey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > Hi, > > im not sure if i am on the right path here, so i figured i would ask. > > Basically, all of my pages have the same header and footer, and i was > wondering if there was some way i could reference this from the rhtml > file? > > from what i have read on partial and template rendering, this is done in > the > controller, but in my case, the header and footer are static, so there is > no > logic. Basically, I am just trying to minimize the number of places i need > to edit in case i make a change to my header or footer (i.e. if i add a > link, i would really like to just update 1 file, rather than do it in all > of > my views). > > Is this possible? thanks! > -- > View this message in context: > http://www.nabble.com/newbie-question-about-rendering-partials-and-rhtml-tf3692733.html#a10324965 > Sent from the RubyOnRails Users mailing list archive at Nabble.com. > > > > >-- http://www.web-buddha.co.uk --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Dave, I read up on layouts, ( http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html?page=2 http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html?page=2 ) and it made me wonder why you cant specify a specific layout inside an action? i tried placing the: layout "standard-layout" inside one of my action def''s, but i ended up with an error. it this not possible? Dave Goodchild wrote:> > Have a look at layouts, that is precisely what they are for. For example, > if > you create an html skeleton, call it application.rhtml and place it in the > layouts folder (in views/), the app will call it by default. In the area > where you want the controller-generated output to go, simply place this > call: > > <% yield %> > > and the magic will take place. > > On 5/4/07, gmoniey <gmoniey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >> >> Hi, >> >> im not sure if i am on the right path here, so i figured i would ask. >> >> Basically, all of my pages have the same header and footer, and i was >> wondering if there was some way i could reference this from the rhtml >> file? >> >> from what i have read on partial and template rendering, this is done in >> the >> controller, but in my case, the header and footer are static, so there is >> no >> logic. Basically, I am just trying to minimize the number of places i >> need >> to edit in case i make a change to my header or footer (i.e. if i add a >> link, i would really like to just update 1 file, rather than do it in all >> of >> my views). >> >> Is this possible? thanks! >> -- >> View this message in context: >> http://www.nabble.com/newbie-question-about-rendering-partials-and-rhtml-tf3692733.html#a10324965 >> Sent from the RubyOnRails Users mailing list archive at Nabble.com. >> >> >> > >> > > > -- > http://www.web-buddha.co.uk > > > > >-- View this message in context: http://www.nabble.com/newbie-question-about-rendering-partials-and-rhtml-tf3692733.html#a10332020 Sent from the RubyOnRails Users mailing list archive at Nabble.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 -~----------~----~----~----~------~----~------~--~---
The "layout ''standard-layout''" call is a class method call that sets the layout for the whole controller. To specify a specific layout for an action, pass it to render: def fooaction # do something render :layout => ''super-special-layout'' end b gmoniey wrote:> > Hi Dave, > > I read up on layouts, ( > http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html?page=2 > http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html?page=2 ) > > and it made me wonder why you cant specify a specific layout inside an > action? i tried placing the: layout "standard-layout" inside one of my > action def''s, but i ended up with an error. > > it this not possible? > > > > Dave Goodchild wrote: >> Have a look at layouts, that is precisely what they are for. For example, >> if >> you create an html skeleton, call it application.rhtml and place it in the >> layouts folder (in views/), the app will call it by default. In the area >> where you want the controller-generated output to go, simply place this >> call: >> >> <% yield %> >> >> and the magic will take place. >> >> On 5/4/07, gmoniey <gmoniey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>> >>> Hi, >>> >>> im not sure if i am on the right path here, so i figured i would ask. >>> >>> Basically, all of my pages have the same header and footer, and i was >>> wondering if there was some way i could reference this from the rhtml >>> file? >>> >>> from what i have read on partial and template rendering, this is done in >>> the >>> controller, but in my case, the header and footer are static, so there is >>> no >>> logic. Basically, I am just trying to minimize the number of places i >>> need >>> to edit in case i make a change to my header or footer (i.e. if i add a >>> link, i would really like to just update 1 file, rather than do it in all >>> of >>> my views). >>> >>> Is this possible? thanks! >>> -- >>> View this message in context: >>> http://www.nabble.com/newbie-question-about-rendering-partials-and-rhtml-tf3692733.html#a10324965 >>> Sent from the RubyOnRails Users mailing list archive at Nabble.com. >>> >>> >> >> -- >> http://www.web-buddha.co.uk >> >> >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
gmoniey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-May-05 18:04 UTC
Re: newbie question about rendering partials and rhtml
thanks for clearing that up...i have another question...this may be more of a design question....our existing website has 2 templates, and we determine which one to show based on screen size, which is determined through javascript...i.e. <script type="text/javascript"> <!-- Begin if(screen.width > xxx) { window.location = "template1"; } else { window.location=''template2"; } // End --> </script> now i am trying to determine how to do this....basically all of my actions behave the same, except they have a different layout... but i am a bit confused...it doesnt seem like i can do this on the server side...i.e. in the controller....or in the .rhtml file...so should i redirect with a id specifying which template? (i.e. set the window.location to specify the id in the url, and then base the template on that? im not sure if i have been very clear...so if this is confusing....let me know...and i''ll try and clear it up... On May 5, 12:50 am, Ben Munat <bmu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The "layout ''standard-layout''" call is a class method call that sets the > layout for the whole controller. > > To specify a specific layout for an action, pass it to render: > > def fooaction > # do something > render :layout => ''super-special-layout'' > end > > b > > gmonieywrote: > > > Hi Dave, > > > I read up on layouts, ( > >http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html?page=2 > >http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html?page=2) > > > and it made me wonder why you cant specify a specific layout inside an > > action? i tried placing the: layout "standard-layout" inside one of my > > action def''s, but i ended up with an error. > > > it this not possible? > > > Dave Goodchild wrote: > >> Have a look at layouts, that is precisely what they are for. For example, > >> if > >> you create an html skeleton, call it application.rhtml and place it in the > >> layouts folder (in views/), the app will call it by default. In the area > >> where you want the controller-generated output to go, simply place this > >> call: > > >> <% yield %> > > >> and the magic will take place. > > >> On 5/4/07,gmoniey<gmon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>> Hi, > > >>> im not sure if i am on the right path here, so i figured i would ask. > > >>> Basically, all of my pages have the same header and footer, and i was > >>> wondering if there was some way i could reference this from the rhtml > >>> file? > > >>> from what i have read on partial and template rendering, this is done in > >>> the > >>> controller, but in my case, the header and footer are static, so there is > >>> no > >>> logic. Basically, I am just trying to minimize the number of places i > >>> need > >>> to edit in case i make a change to my header or footer (i.e. if i add a > >>> link, i would really like to just update 1 file, rather than do it in all > >>> of > >>> my views). > > >>> Is this possible? thanks! > >>> -- > >>> View this message in context: > >>>http://www.nabble.com/newbie-question-about-rendering-partials-and-rh... > >>> Sent from the RubyOnRails Users mailing list archive at Nabble.com. > > >> -- > >>http://www.web-buddha.co.uk--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Dave Goodchild
2007-May-05 20:08 UTC
Re: newbie question about rendering partials and rhtml
I guess it depends how much of the difference between the two templates is presentational is handled by css. If so, the javascript can still do it''s thing. The rhtml layouts should only contain structural information (ie html/xhtml). Clarify a little more? On 5/5/07, gmoniey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <gmoniey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > thanks for clearing that up...i have another question...this may be > more of a design question....our existing website has 2 templates, and > we determine which one to show based on screen size, which is > determined through javascript...i.e. > > <script type="text/javascript"> > <!-- Begin > if(screen.width > xxx) > { > window.location = "template1"; > > } > else { > window.location=''template2"; > } > // End --> > </script> > > now i am trying to determine how to do this....basically all of my > actions behave the same, except they have a different layout... > > but i am a bit confused...it doesnt seem like i can do this on the > server side...i.e. in the controller....or in the .rhtml file...so > should i redirect with a id specifying which template? (i.e. set the > window.location to specify the id in the url, and then base the > template on that? > > im not sure if i have been very clear...so if this is confusing....let > me know...and i''ll try and clear it up... > > > On May 5, 12:50 am, Ben Munat <bmu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > The "layout ''standard-layout''" call is a class method call that sets the > > layout for the whole controller. > > > > To specify a specific layout for an action, pass it to render: > > > > def fooaction > > # do something > > render :layout => ''super-special-layout'' > > end > > > > b > > > > gmonieywrote: > > > > > Hi Dave, > > > > > I read up on layouts, ( > > >http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html?page=2 > > >http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html?page=2) > > > > > and it made me wonder why you cant specify a specific layout inside an > > > action? i tried placing the: layout "standard-layout" inside one of my > > > action def''s, but i ended up with an error. > > > > > it this not possible? > > > > > Dave Goodchild wrote: > > >> Have a look at layouts, that is precisely what they are for. For > example, > > >> if > > >> you create an html skeleton, call it application.rhtml and place it > in the > > >> layouts folder (in views/), the app will call it by default. In the > area > > >> where you want the controller-generated output to go, simply place > this > > >> call: > > > > >> <% yield %> > > > > >> and the magic will take place. > > > > >> On 5/4/07,gmoniey<gmon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > >>> Hi, > > > > >>> im not sure if i am on the right path here, so i figured i would > ask. > > > > >>> Basically, all of my pages have the same header and footer, and i > was > > >>> wondering if there was some way i could reference this from the > rhtml > > >>> file? > > > > >>> from what i have read on partial and template rendering, this is > done in > > >>> the > > >>> controller, but in my case, the header and footer are static, so > there is > > >>> no > > >>> logic. Basically, I am just trying to minimize the number of places > i > > >>> need > > >>> to edit in case i make a change to my header or footer (i.e. if i > add a > > >>> link, i would really like to just update 1 file, rather than do it > in all > > >>> of > > >>> my views). > > > > >>> Is this possible? thanks! > > >>> -- > > >>> View this message in context: > > >>> > http://www.nabble.com/newbie-question-about-rendering-partials-and-rh... > > >>> Sent from the RubyOnRails Users mailing list archive at Nabble.com. > > > > >> -- > > >>http://www.web-buddha.co.uk > > > > >-- http://www.web-buddha.co.uk --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
gmoniey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-May-05 22:40 UTC
Re: newbie question about rendering partials and rhtml
the two layouts are actually very different...different images, different static text, different tables, div''s etc... i have been thinkin about this more and more..and it seems like the best way to do it would be something like this: <script type="text/javascript"> <!-- Begin if(screen.width > xxx) { window.location = "http://www.mysite.com/template2"; } else { window.location=''http://www.mysite.com/template1"; } // End --> </script> and have the action handle which template will be shown from there on out (since this really only need to be figured out the first time the page loads), however...im worried about the case where the user wanted to go back to the homepage...i.e. http://www.mysite.com, i would need a way to ensure that the javascript is run again... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jamal Soueidan
2007-May-05 23:49 UTC
Re: newbie question about rendering partials and rhtml
gmoniey wrote:> Hi, > > im not sure if i am on the right path here, so i figured i would ask. > > Basically, all of my pages have the same header and footer, and i was > wondering if there was some way i could reference this from the rhtml > file? >In the view you can do this <%= render "blog/header" %> blah lbah <%= render "blog/footer" %> PS: I would rather create one layout which include header and footer :) -- 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 -~----------~----~----~----~------~----~------~--~---