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.
On Wed, Dec 17, 2008 at 9:37 AM, Zhao Yi
[email protected] 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
Franz S. wrote:
On Wed, Dec 17, 2008 at 9:37 AM, Zhao Yi
[email protected] 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.
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
Or you can set layout directly in your controller:
class MyController < ApplicationController
layout ‘some_other_layout’
end
Regards,
Bosko
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.
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.
Bosko wrote:
Or you can set layout directly in your controller:
class MyController < ApplicationController
layout ‘some_other_layout’
end
Regards,
Bosko
Hi,
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
John Y. 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.
Ruby on Rails - Layouts
Oh, rails handles the automatic linking with the layout and views.
thanks.