Your task is to build an online store! Okay, maybe not a whole online store, but at least some layouts and controllers for an online store. Not only will you learn how to create a layout and how to get an action to use that layout, but also how to override defaults and specify layouts on an action level.
- Make a new controller called
StaticController
- Create a home action with an
h2
that says "Welcome to Flatiron Widgets" and a new action inStaticController
calledhome
- Create a default application layout at the correct location and add an
h1
to it that says "Flatiron Widgets Store", this is for the main site's welcome bar
- Create a new controller called
StoreAdminController
- We want this controller to use a new layout called
admin
. This layout should have anh1
that says "Flatiron Widgets: Admin" - Create a home action in
StoreAdminController
with anh2
that says "Welcome Flatiron Admin" - Get your newly created action to use the
admin
template
- Create a new action in
StoreAdminController
calledorders
, with anh2
that says "Welcome to Flatiron Open Orders". Also add anol
with a fewli
elements containing fake orders. - Now you should create a new layout called
order_administration
, and add anh1
that says "Flatiron Widgets: Open Orders" - At this point the store_admin#orders action will use the
admin
layout you defined earlier, but we need it to use the neworder_administration
layout. The trick is, we want only thestore_admin#orders
action to use theorder_administration
layout, and keep theadmin
layout as the default for the other actions inStoreAdminController
.
- Create a new action in
StoreAdminController
calledinvoice
, and insert anh1
containing that says "Your Invoice" - At this point this action will use the default layout for the controller, which is
admin
. We need this specificinvoice
action to not use any layout at all, while not affecting the other actions in the controller.