Contributing to Ruby on Rails is Not Hard - Here's How You Can Suggest a New Feature
A guide to becoming a Ruby on Rails contributor.
The Ruby on Rails community is always welcoming new contributors. They are very supportive of people learning the system at many levels. For example, you could make additions to its documentation, fix bugs, or suggest new features. In this article, I will show you how you can propose a new idea for Ruby on Rails. Then take it from conception all the way to implementation.
- Discuss your idea with the Rails core team
- Create a patch
- Open a pull request
- Merged! You have become a Rails Contributor
- Find out more
It’s useful to refine any ideas you have. Take a look at the Ruby on Rails codebase on GitHub to see how it could fit into the existing structure.
The Rails Guide to Contributing to Ruby on Rails covers the key things you need to know about its workflow. It covers using its GitHub repo to report issues, cloning the project and running the test suite.
Tip: If you are just starting out on your open source journey, you might want to try contributing to the Ruby on Rails documentation first to get a feel for the workflow.
If you approach contributing with a positive attitude and are willing to learn from other Rails contributors — you’ll be in good company. It is a great opportunity to collaborate and learn about writing clean, consistent code for a large codebase.
Once you feel comfortable with your idea you can suggest your idea in the Google group for the Rails core team.
Discuss your idea with the Rails core team
Rather than opening an issue on the Ruby on Rails GitHub repo, feature requests are discussed in the Google group for the Ruby on Rails: Core.
This is where you can put forward your idea and get feedback from experienced Ruby on Rails contributors. Expect there to be some discussion around the implementation and reasons for including any new features.
If they give you the go ahead to submit a patch, you then need to clone the Ruby on Rails repo to add your code.
Create a patch
Once you have set up your development environment with Ruby, you need to clone the Ruby on Rails GitHub repo. The Rails Guide to Contributing to Ruby on Rails gives you detailed guidance on how you can use git branches and forks as part of the development workflow.
Now write your code!
Ruby on Rails is built on various principles outlines in the Ruby on Rails Doctrine. One of them is Convention over Configuration, so writing new code means sticking to the established conventions. Here are some of the tips from the Rails Guide to help you write code that will be accepted into the Rails codebase.
- Get the code right.
- Use Rails idioms and helpers.
- Include tests that fail without your code, and pass with it.
- Update the (surrounding) documentation, examples elsewhere, and the guides: whatever is affected by your contribution.
In addition, there is a list of code style conventions to follow, which can help you be consistent with established practices. In addition, the Ruby on Rails codebase uses the linter RuboCop to support following code style conventions.
Once you have written your new feature and run the tests successfully, you should be ready to open a pull request.
Open a pull request
Once you open a pull request, members of the Rails core and committer teamswill review it and give you feedback. You may develop your feature further here and learn how to refine your code before it is accepted into the Ruby on Rails codebase.
Most pull requests will go through a few iterations before they get merged. Different contributors will sometimes have different opinions. Often patches will need to be revised before they can get merged. — Get Some Feedback | Rails Guide
They could suggest an alternative approach to implementing your feature. They may suggest you make the code more efficient. They may suggest that you write tests and Changelog entries in a way that is clear and consistent with the existing code.
It’s entirely possible that the feedback you get will suggest changes. Don’t get discouraged: the whole point of contributing to an active open source project is to tap into the knowledge of the community. If people are encouraging you to tweak your code, then it’s worth making the tweaks and resubmitting. If the feedback is that your code doesn’t belong in the Ruby on Rails core project, you might still think about releasing it as a gem. — Iterate as Necessary | Rails Guide
Once you have responded to feedback and addressed any outstanding issues, your code will be merged into the Ruby on Rails codebase.
Merged! You have become a Rails Contributor
Congratulations on your contribution to Ruby on Rails! You are now an official contributor!
All contributors are added to a list of the commits people made to Ruby on Rails. You will be able to see your name and the commit you made on the website contributors.rubyonrails.org.
Find out more
While challenging at times, contributing to open source projects, such as Ruby on Rails, can be a valuable experience. There is much to learn from the community that surrounds them that will help you become a better developer. Plus you have the satisfaction of having code you wrote being used by others.
Once you have made your first contribution, you might feel like contributing more to Ruby on Rails — or other open source projects.