Holds the template files for layouts to be used with views. This models the common header/footer method of wrapping views. In your views, define a layout using the <tt>layout :default</tt> and create a file named default.rhtml. Inside default.rhtml, call <% yield %> to render the view using this layout. This text is from official readme. I do not know where to write "layout :default", and where to put default.rhtml file.... I used to put "layout :default" in application.rb, so all page use this layout, but now, it does not work.... 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?hl=en -~----------~----~----~----~------~----~------~--~---
> Holds the template files for layouts to be used with views. This > models the common > header/footer method of wrapping views. In your views, define a > layout using the > <tt>layout :default</tt> and create a file named default.rhtml. > Inside default.rhtml, > call <% yield %> to render the view using this layout. > > This text is from official readme. I do not know where to write > "layout :default", and where to put default.rhtml file.... > I used to put "layout :default" in application.rb, so all page use > this layout, but now, it does not work....Create: app/views/layouts/default.rhtml... Then in app/controllers/application.rb put b/n the class...end block. layout ''default'' --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom wrote:>> Holds the template files for layouts to be used with views. This >> models the common >> header/footer method of wrapping views. In your views, define a >> layout using the >> <tt>layout :default</tt> and create a file named default.rhtml. >> Inside default.rhtml, >> call <% yield %> to render the view using this layout. >> >> This text is from official readme. I do not know where to write >> "layout :default", and where to put default.rhtml file.... >> I used to put "layout :default" in application.rb, so all page use >> this layout, but now, it does not work.... > > Create: app/views/layouts/default.rhtml... > > Then in app/controllers/application.rb put b/n the class...end block. > > layout ''default''However you only need to do that if you want your layout to be called "default" for some reason. If you call your layout rhtml file application.rhtml, then that layout will be used automatically... no need to specify it in application.rb. If you need different layouts for different parts of your app, you can make additional layout files and using the "layout ''layoutname''" call in the appropriate controller... or name the layout file the same name as your controller (as scaffolding does) and it will get used automatically for calls to that controller. b --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
It seems that it does not work, i make a app/views/layouts/ application.rhtml file, and it does not work as a default layout.... On 4月24日, 上午2时30分, Ben Munat <bmu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> However you only need to do that if you want your layout to be called > "default" for some reason. If you call your layout rhtml file > application.rhtml, then that layout will be used automatically... no > need to specify it in application.rb.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hmm, works for me... Are you sure you haven''t set a "layout ''something''" in the controller you''re calling? b Magicloud wrote:> It seems that it does not work, i make a app/views/layouts/ > application.rhtml file, and it does not work as a default layout.... > > On 4月24日, 上午2时30分, Ben Munat <bmu...@gmail.com> wrote: >> However you only need to do that if you want your layout to be called >> "default" for some reason. If you call your layout rhtml file >> application.rhtml, then that layout will be used automatically... no >> need to specify it in application.rb. > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
bkocik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-28 14:36 UTC
Re: What does this mean?
On Apr 23, 4:53 am, Magicloud <magicloud.magiclo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> This text is from official readme. I do not know where to write > "layout :default", and where to put default.rhtml file....You can specify the layout in your controller. If you want to have a default layout, it''s best to name it "application.rhtml" (or .rxml, or whichever). Rails will use that as the default for any controller that doesn''t have its own layout. Layouts go in "your_application/app/views/ layouts" by convention, and Rails will look for them there. So, how does a controller get its own layout? Two ways. The most common is simply by naming a layout after the controller. For example, if you have a controller called "FooController", then Rails will look for a layout called "foo.rhtml" (or .rxml, or whichever) first. The second way is to explicitly name the layout you want applied to the views of a controller within the controller itself (this is where "layout :default" comes in). Say you want FooController to have the "bar" layout instead: class FooController < ApplicationController layout "bar" . . . end Layouts are inherited, so if FoobarController extends FooController, it will also get the "bar" layout unless you specify otherwise. Finally, the "layout" declaration can actually take arguments beyond just strings, so you can conditionally apply layouts and do all sorts of other craziness if that sort of thing turns you on. --~--~---------~--~----~------------~-------~--~----~ 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 am trying to use an inherited hook: module StarMonkey class MyStarMonkey def self.inherited(klass) puts klass.const_defined(''LIKES_CRUNCHY_BACON'') end end end My personal star monkey class FredrickTheGreat < StarMonkey::MyStarMonkey LIKES_CRUNCHY_BACON = ''hello world!'' end now for IRB goodness: >> puts FredrickTheGreat.const_defined?(''LIKES_CRUNCY_BACON'') => true => true seems to work. now for something more real life The hook module ActiveRecord class Base def slef.inherited(klass) puts klass.has_const(''LIKES_CRUNCHY_BACON'') end end end Model class StarMonkey < ActiveRecord::Base LIKES_CRUNCHY_BACON = true end script/console --- >> puts StarMonkey.const_defined?(''LIKES_CRUNCHY_BACON'') =>false #this is my inherited hook =>true What gives? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---