Rails 8 新项目创建
Rails 8.0.1 has some new features. + ruby 3.4.2
rvm install 3.4.2
gem install rails -v 8.0.1
It's the time to begin to build the project. But first, what problem do you want to solve? Yes , there is a requirement, I want to build a project about 'Wuxing BaGua'.
The project name is 'zybzlz'.
rvm install 3.4.2
gem install rails -v 8.0.1
It's the time to begin to build the project. But first, what problem do you want to solve? Yes , there is a requirement, I want to build a project about 'Wuxing BaGua'.
The project name is 'zybzlz'.
rails new zybzlz -T --css=tailwind --database=postgresql rails tailwindcss:install rails assets:precompile
The -T flag prevents Rails from generating files fro MiniTest, as we will use Rspec for testing.
The --css tailwind flag sets up Tailwind CSS for styling.
The --database=postgresql flag configures PostgreSQL as the database.
bundle install
You can change the gem source ,if you're in China and stuck. (ruby-china or 163 or tencent is ok.)
config your config/database.yml
rails db:create && rails db:migrate
Tailwindcss
Synopsis:
- bin/rails tailwindcss:install - installs the configuration file, output file, and Procfile.dev
- bin/rails tailwindcss:build - generate the output file
- bin/rails tailwindcss:build[debug] - generate unminimized output
- bin/rails tailwindcss:watch - start live rebuilds, generating output on file changes
- bin/rails tailwindcss:watch[debug] - generate unminimized output
- bin/rails tailwindcss:watch[poll] - for systems without file system events
- bin/rails tailwindcss:watch[always] - for systems without TTY (e.g., some docker containers)
Note that you can combine task options, e.g. rails tailwindcss:watch[debug,poll].
Chartkick
#Gemfile gem 'chartkick' gem 'groupdate' Configuring Chartkick Using Importmap
In config/importmap.rb, add:
pin "chartkick", to: "chartkick.js" pin "Chart.bundle", to: "Chart.bundle.js"
And in app/javascript/application.js, add:
import "chartkick" import "Chart.bundle"
Ruby:
@posts_by_month = Post.group_by_month(:created_at).count
erb:
<%= column_chart @posts_by_month %>
阅读量: 343
发布于:
修改于:
发布于:
修改于: