- Create a new Rails project named Styles.
- Generate a controller named Inline with a view named page1.
- Source code for Styles/app/views/inline/page1.html.erb:
<h1>Styles Example</h1>
<h2>Inline Controller</h2>
<p style="font: normal 400% Arial; color: maroon;">
This is a test.
</p>
- Remove this line from the file Styles/app/views/layouts/application.html.erb:
<%= javascript_include_tag 'application',
'data-turbolinks-track' => true %>
- Generate a controller named DocLevel with a view named page2.
- Source code for Styles/app/views/doc_level/page2.html.erb:
<h1>Styles Example</h1>
<h2>DocLevel Controller</h2>
<p>This is a test.</p>
- Create the file Styles/app/views/layouts/doc_level.html.erb
and add to it this content:
<!DOCTYPE html>
<html>
<head>
<title>Styles</title>
<%= stylesheet_link_tag 'application', media: 'all',
'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
<style>
h1, h2 { font-family: Arial; }
p { font: normal 400% Arial; color: maroon; }
</style>
</head>
<body>
<%= yield %>
</body>
</html>
- Generate a controller named External with a view named
page3.
- Source code for Styles/app/views/external/page3.html.erb:
<h1>Styles Example</h1>
<h2>External Controller</h2>
<p>This is a test.</p>
- Source code for Styles/app/assets/stylesheets/external.scss:
h1, h2 { font-family: Verdana; }
p { font: normal 300% Verdana;
color: maroon; }
- View pages 1, 2, and 3 with these URLs:
http://localhost:3000/inline/page1
http://localhost:3000/doc_level/page2
http://localhost:3000/external/page3