We are working on an ecommerce site with Spree that needs quite a bit of customisation to the standard Spree5 platform. Some of that is specific to the project, but some of it might be useful to other Spree users.
Hello! An opportunity to join in and contribute back to this amazing project.
Getting started is a lot easier than you might think. Just follow the guide!
- Make your own Spree version to work on; fork the repo on github.
- Clone it down to your machine:
git clone git://github.com/your_github_username/spree.git cd spree
- Run: bundle install
- Make a sandbox site:
bin/sandbox.sh
- Start the site:
bin/dev
Ok, whlle doing that, I immediately got distracted by something that needed updating in the docs. The default login for the sandbox was incorrect. Easy pickings like helping proof read documentation is a great way to get started contributing to open source.
git branch fix/default-user
git checkout fix/default-user
Then I just needed to edit the file in the docs:
code docs/developer/contributing/developing-spree.mdx
Then push my branch up, and follow the prompts to make a pull request. After a few days the super helpful devs at Spree had reviewed and merged it. Eeek! Exciting. LET'S DO MORE!
So next I wanted to add some features to allow us to use SpreeUserRoles in our site.
Filter users by role in the admin user index page.
git branch feature/filter-by-role
git checkout feature/filter-by-role
Then we just need to make some simple edits to the _filters.html.erb - to add the form field, users_helper.rb to select roles in the field and user_methods to allow the attribute in the search system. These were all simple standard RubyOnRails code changes. No deep knowledge of anything mysterious or Spree specific needed. And boom, I've added a feature.
Show User Roles
So repeating that process, I could easily show what roles a user belonged to in the admin user show page:
Editing Roles
Same again to allow editing of a user's roles when editing a user in the admin area. Create the branch on my local machine, make the little change needed. Commit and push the change to github and follow the prompts to create a pull request.
Feature Complete
And that's all the work done! We can edit Roles, view Roles and filter users by role. Even better, we have shared it with the community so everybody can benefit, and the platform is that tiny little bit stronger.
You can see from the commits that a deep knowledge of Spree isn't needed to get started. Rails is easy to understand and all the code is where you would expect it to be as it is split up into the normal Models, Views and Controllers sections.
Extra Benefits
When contributing to open source, you get these extra benefits.
- A nice way to say thank you and hello to the developers
- Learning about how the project's code works and what its dependencies are helps debug problems through better understanding.
- Exciting and fun to contribute to these big projects
- Grow as a developer by working with other developers on large codebases.
Leave a Reply
Comments
No comments on this article.
comments powered by Disqus