justingoodman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Oct-20 20:18 UTC
Template question
I developed a simple blog for myself and friends to keep in touch with family back home. My structure consists of an account controller and a blog controller, which handles the basic database I/O. However, im very new to rails. What I want to do is load all my calls in the same web layout. I heard partials are the way to go with this sort of usage, can someone explain to me or direct me to a very detailed guide on how to best do this? I looked at the definition of partials and such, but it doesn''t explain (at least not in plain english) how to make a global template page that simply calls all the partials as needed. Help would be greatly appreciated, 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 -~----------~----~----~----~------~----~------~--~---
create a file app/views/layouts/application.rhtml. Put your layout in that, then where you want the actual page to go, put <%= @content_for_layout %> As long as there''s not another layout in that folder by the same name as the controller, all views will be automatically put inside that layout. Partials ARE the way to go, but they''re more for small sections of a page that you may want to include on multiple pages. inside the view, you do <%= render :partial => ''section1'' %> then in your views folder have a file called _section1.rhtml. It will be inserted. Happy coding! justingoodman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> I developed a simple blog for myself and friends to keep in touch with > family back home. > > My structure consists of an account controller and a blog controller, > which handles the basic database I/O. > > However, im very new to rails. What I want to do is load all my calls > in the same web layout. I heard partials are the way to go with this > sort of usage, can someone explain to me or direct me to a very > detailed guide on how to best do this? I looked at the definition of > partials and such, but it doesn''t explain (at least not in plain > english) how to make a global template page that simply calls all the > partials as needed. > > Help would be greatly appreciated, > 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 -~----------~----~----~----~------~----~------~--~---
justingoodman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Oct-20 22:41 UTC
Re: Template question
Thanks, it worked great! I got it running exactly how I wanted it. One other question though, im sure I''ll learn from experimentation, but i''ll ask anyway. I have two controllers, blog and account. My blog controller has my basic MySQL functions (post, edit, delete, list). My account controller has my login/logout/create user functions. I want to link to my functions in account from the blog controller. How would I go about doing that? My app is done in function, just trying to organize it now, so it''s mostly tweaking for me now. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---