This article discusses the same topic as the previous article, but where the previous article used a CDN-hosted CSS framework, this article will use local CSS files and copy them into the project folder.
rails serve
The time before command is used to display the total time of command execution. The following example took 47 seconds. <code>$ rails -v Rails 8.0.0 $ time rails new classless-css-local ... real 0m47.500s user 0m33.052s sys 0m4.249s</code>
Rails 8, based on its "no build" philosophy, uses Propshaft as the asset pipeline library and Importmap as the JavaScript library by default. Importmap does not do anything with JavaScript.
<code>$ rails -v Rails 8.0.0 $ time rails new classless-css-local ... real 0m47.500s user 0m33.052s sys 0m4.249s</code>
app/views/layouts/application.html.erb
<code>$ cd classless-css-local && code .</code>
<head>
tag contains important structural elements for page rendering and normal operation. The <head>
tag is used to contain metadata and important resources that help configure the page's behavior (using JavaScript), appearance (using CSS), association with other systems and services, and security configuration, such as CSRF and CSP protection; <body>
via the ERB tag. This tag serves as an integration point for containing Rails dynamically rendered view content; localhost:3000/pages/html_test_1
localhost:3000/pages/html_test_2
localhost:3000/pages/html_test_3
localhost:3000/pages/html_test_4
config/routes.rb
file<code class="language-html"> <title></title><meta content="width=device-width,initial-scale=1" name="viewport"></meta><meta content="yes" name="apple-mobile-web-app-capable"></meta><meta content="yes" name="mobile-web-app-capable"></meta><link href="/icon.png" rel="icon" type="image/png"></link><link href="/icon.svg" rel="icon" type="image/svg+xml"></link><link href="/icon.png" rel="apple-touch-icon"></link></code>
--skip-routes
parameter is passed when creating the controller, you can ignore adding routes for the created action.The complete command will become rails g controller pages html_test_1 html_test_2 html_test_3 html_test_4 --skip-routes
<code>$ rails -v Rails 8.0.0 $ time rails new classless-css-local ... real 0m47.500s user 0m33.052s sys 0m4.249s</code>
Alternatively, you can use the following command to display all routes:
<code>$ cd classless-css-local && code .</code>
http://127.0.0.1:3000/rails/info/routes
. Remember to start the development server using bin/dev
or the standard Rails server using rails server
in the project root. The development server "listens" for changes to JavaScript and CSS files in order to do the necessary processing and serve them to the user. Ruby on Rails uses the MVC (Model-View-Controller) architecture by default to initiate project organization. Most of the code is organized in the following folders:
app/models
folder; app/views
folder; app/controllers
folder; Due to space limitations, subsequent steps will be omitted. Please note that the above has been pseudo-originalized from the original text and retains the original format and location of the image. A complete pseudo-original would require a similar rewriting of the remainder.
The above is the detailed content of Ruby on Rails Frontend Rápido com Frameworks CSS Classless ou Class-Light sem CDN. For more information, please follow other related articles on the PHP Chinese website!