Ruby on Rails 8 的 API 样板项目
Rails API Base is a boilerplate project for JSON RESTful APIs. It follows the community best practices in terms of standards, security and maintainability, integrating a variety of testing and code quality tools. It's based on Rails 8.1 and Ruby 4.0.
Finally, it contains a plug an play Administration console (thanks to ActiveAdmin).
This template comes with:
.nvmrc file.corepack enable to install the required yarn binaries. Corepack is already included in newest node versions.bootstrap.sh with the name of your project like ./bin/bootstrap.sh --name=my_awesome_project.yarn install and yarn build --watch. This bundles the JS assets in the administration site using esbuild.bundle exec rspec and make sure all tests pass (non-headless mode) or HEADLESS=true bundle exec rspec (headless mode)bin/dev.docker and docker-compose installed (You can check this by doing docker -v and docker-compose -v)bootstrap.sh with the name of your project and the -d or --for-docker flag like ./bin/bootstrap.sh --name=my_awesome_project -d./bin/bootstrap.sh --help for the full details.docker-compose network, remove the ports key in the docker-compose.yml from the db service.bin/rspec ..See Docker docs for more info
This template provides a handful of scripts to make your dev experience better!
bundle commands.bin/bundle installrails commandsbin/rails consolebash commandsbin/web lsbin/rspec .bin/devYou don't have to use these but they are designed to run the same when running with Docker or not.
To illustrate, bin/rails console will run the console in the docker container when running with docker and locally when not.
This template includes built-in email delivery support via SendGrid, using Rails' Action Mailer.
Email sending with SendGrid is enabled by configuring the environment variable:
SENDGRID_API_KEY=your_api_keyconfig/initializers/rack_cors.rbconfig/initializers/devise.rbapplication.rbSee API documentation docs for more info
With bundle exec rails code:analysis you can run the code analysis tool, you can omit rules with:
.rubocop.ymlconfig.reekconfig/rails_best_practices.ymlbrakeman -I to generate config/brakeman.ignoreThe project uses SonarQube Community Edition to ensure code quality and monitor test coverage. The configuration can be found in sonar-project.properties.
To set up SonarQube:
export SONAR_TOKEN=your_token
export SONAR_HOST_URL=http://localhost:9000bundle exec rspec
sonar-scannerFor more details about the CI process and SonarQube setup, check the CI documentation.
brew install hadolint and run hadolint Dockerfile*. Edit .hadolint.yml to omit additional rules.This template ships with project-level Claude Code skills under .claude/skills/ that auto-activate while Claude edits code in your project:
ruby-conventions — triggers on Ruby files; applies Rootstrap's Ruby style guide.rails-conventions — triggers on Rails code (controllers, models, migrations, config); applies Rootstrap's Rails conventions.rspec-conventions — triggers on spec files; applies Rootstrap's RSpec style guide.They are distilled from rootstrap/tech-guides. No setup required — Claude Code loads them automatically based on the files being edited. If you don't use Claude Code, or want to customize the conventions, simply edit or remove the files under .claude/skills/.
The rails_api_base incorporates a user impersonation feature, allowing AdminUsers to assume the identity of other Users. This feature is disabled by default.
See Impersonation docs for more info
In order to use New Relic to monitor your application requests and metrics, you must setup NEW_RELIC_API_KEY and NEW_RELIC_APP_NAME environment variables.
To obtain an API key you must create an account in the platform.
You can use CODEOWNERS file to define individuals or teams that are responsible for code in the repository.
Code owners are automatically requested for review when someone opens a pull request that modifies code that they own.
Rails API Base is maintained by Rootstrap with the help of our contributors.
暂无开放 Issues,或尚未同步最近议题。