-
Notifications
You must be signed in to change notification settings - Fork 744
Backend Practices
Our backend is in Ruby on Rails and follows the typical file and folder structure of scaffolded apps. To learn more read the official Getting Started with Rails guide.
- We use 2 space indentation.
- We use snakecase for Ruby files and id/class names in HTML.
- We use single quotes for Ruby files.
- We follow Airbnb's Ruby style guide
Rubocop is a Ruby static code analyzer that we also integrate in Codeclimate, an automated code review we run when pull requests are made.
rubocop
Ruby on Rails encourages various patterns to yield modularity in the codebase. It can be tricky to figure out where you want your code to go.
- Business logic: Operations that get carried out when Models calls are made
- Modularity: Separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality
- Mixins: A class that contains methods for use by other classes without having to be the parent class of those other classes
- Dependency-free
- No business logic
- Mixins
- Can have dependencies
- Business logic
- Presentation methods that are called from your views or controllers
If you add or modify a model, please run annotate
to update the schema comments and rake db:drop db:create db:migrate; rake db:schema:load
to update db/schema.rb
.
Please see our Automated Testing document, specifically the backend document.
Running bundle update
will update all gems and modify Gemfile.lock
.
You can also run bundle exec bundle-audit check --ignore CVE-2015-9284 --update
to check for security vulnerabilities in gems. We're ignoring CVE-2015-9284
because there is still no update on a CSRF vulnerability for OmniAuth. This PR has more info.