Giter Site home page Giter Site logo

rails-layouts-and-templates-lab-houston-web-100818's Introduction

Rails Layouts And Templates Lab

Objectives

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 the action level.

The Default Layout

  1. Make a new controller called StaticController.
  2. Create a home view with an h2 that says "Welcome to Flatiron Widgets" and a new action in StaticController called home.
  3. 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.

Custom Layouts for a Controller

  1. Create a new controller called StoreAdminController.
  2. We want this controller to use a new layout called admin. This layout should have an h1 that says "Flatiron Widgets: Admin".
  3. Create a home view in StoreAdminController with an h2 that says "Welcome Flatiron Admin".
  4. Get your newly created action to use the admin template.

Custom Layouts for an Action

  1. Create a new view in StoreAdminController called orders with an h2 that says "Welcome to Flatiron Open Orders". Also add an ol with a few li elements containing fake orders.
  2. Now you should create a new layout called order_administration and add an h1 that says "Flatiron Widgets: Open Orders".
  3. At this point, the store_admin#orders action will use the admin layout you defined earlier, but we need it to use the new order_administration layout. The trick is we want only the store_admin#orders action to use the order_administration layout, and we want to keep the admin layout as the default for the other actions in StoreAdminController.

Ignore Layouts for an Action

  1. Create a new action in StoreAdminController called invoice, and insert an h1 that says "Your Invoice".
  2. This action is assigned the default layout for the controller, admin, but we don't want it to use any layout at all (while also not affecting the layouts assigned to other actions in the controller).

View Rails Layouts And Templates Lab on Learn.co and start learning to code for free.

View Layouts And Templates in Rails Lab on Learn.co and start learning to code for free.

rails-layouts-and-templates-lab-houston-web-100818's People

Contributors

hendrikswan avatar blake41 avatar annjohn avatar aviflombaum avatar perpepajn25 avatar danielseehausen avatar fidelscodes avatar jmburges avatar

Watchers

 avatar Kevin McAlear avatar  avatar Victoria Thevenot avatar Belinda Black avatar  avatar Joe Cardarelli avatar Sam Birk avatar Sara Tibbetts avatar The Learn Team avatar Sophie DeBenedetto avatar  avatar Jaichitra (JC) Balakrishnan avatar Antoin avatar Alex Griffith avatar  avatar Amanda D'Avria avatar  avatar A. Perez avatar Nicole Kroese  avatar  avatar Lore Dirick avatar Nicolas Marcora avatar Lisa Jiang avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.