I use ruby script/generate controller mycontroller to create a controller. There app/views/mycontroller/* include all the view files. But I didn''t find there is any layout files associated with these views. How can I generate a layout for these views? thanks. -- 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 -~----------~----~----~----~------~----~------~--~---
On Wed, Dec 17, 2008 at 9:37 AM, Zhao Yi <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I use ruby script/generate controller mycontroller to create a > controller. There app/views/mycontroller/* include all the view files. > But I didn''t find there is any layout files associated with these views. > How can I generate a layout for these views?Create the layout under app/views/layouts and depending on your version of rails: 1.x - mycontroller.rhtml 2.x - mycontroller.html.erb --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Franz Strebel wrote:> On Wed, Dec 17, 2008 at 9:37 AM, Zhao Yi > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >> I use ruby script/generate controller mycontroller to create a >> controller. There app/views/mycontroller/* include all the view files. >> But I didn''t find there is any layout files associated with these views. >> How can I generate a layout for these views? > > Create the layout under app/views/layouts and depending on your > version of rails: > > 1.x - mycontroller.rhtml > 2.x - mycontroller.html.erbIf I create this layout file manually, how will rails link it to the views? Which URL refer to this layout? thanks. -- 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 -~----------~----~----~----~------~----~------~--~---
Hi.., It will take automatically. app/view/layout/ Here layout folder is meant for layouts For any controller you can use layout by naming layout file as same name as controller.. Regards hafeez On Wed, Dec 17, 2008 at 2:20 PM, Zhao Yi <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>wrote:> > Franz Strebel wrote: > > On Wed, Dec 17, 2008 at 9:37 AM, Zhao Yi > > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > >> > >> I use ruby script/generate controller mycontroller to create a > >> controller. There app/views/mycontroller/* include all the view files. > >> But I didn''t find there is any layout files associated with these views. > >> How can I generate a layout for these views? > > > > Create the layout under app/views/layouts and depending on your > > version of rails: > > > > 1.x - mycontroller.rhtml > > 2.x - mycontroller.html.erb > > If I create this layout file manually, how will rails link it to the > views? Which URL refer to this layout? > > thanks. > -- > 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 -~----------~----~----~----~------~----~------~--~---
Or you can set layout directly in your controller: class MyController < ApplicationController layout ''some_other_layout'' end Regards, Bosko --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> If I create this layout file manually, how will rails link it to the > views? Which URL refer to this layout?You can specify which layout to use in your controller. layout ''main'' That would use app/views/layouts/main.html.erb as the layout. You can specify a default global layout by placing this in the application controller. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bosko wrote:> Or you can set layout directly in your controller: > > class MyController < ApplicationController > layout ''some_other_layout'' > end > > Regards, > BoskoHi, I set this in my controller and which link I should use for this layout. When I invoke the controller in the browser, it will refer to the index page not the layout page. Thanks, Zhao Yi -- 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 -~----------~----~----~----~------~----~------~--~---
> I set this in my controller and which link I should use for this layout. > When I invoke the controller in the browser, it will refer to the index > page not the layout page.Give this a read - it explains layouts and how to use them better than I can here. http://www.tutorialspoint.com/ruby-on-rails/rails-layouts.htm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
John Yerhot wrote:>> I set this in my controller and which link I should use for this layout. >> When I invoke the controller in the browser, it will refer to the index >> page not the layout page. > > Give this a read - it explains layouts and how to use them better than > I can here. > > http://www.tutorialspoint.com/ruby-on-rails/rails-layouts.htmOh, rails handles the automatic linking with the layout and views. thanks. -- 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 -~----------~----~----~----~------~----~------~--~---