Open Source Contribution to Spree/Solidus
This was one of the open source contribution in 2015 to a major Rails project used by e-commerce companies.
It usually takes hours/days to understand the basic framework, goals, motivations, features vs limitations etc., to start contributing to an open source project based on the amount of domain knowledge (especially for matured projects).
Its usually hard to find and understand bugs in a very well mature framework or language. One of the good things about using open source libraries is you get to know both the code and get to know the eco system while getting paid on the job.
I found a bug in the admin section of Spree. The images when re-ordered are not maintaining their position. I identified this issue while trying to work on a similar feature to order categories.
I made a fix locally to verify it has solved the issue and later fixed it
Steps to reproduce the Issue:
1. Go to images under product. 2. Take any element after the 1st one to the top. 3. Edit the one at the top (that was just dragged) 4. Coming back to the index page shows it in the 2nd position.
What is happening in the frontend?
This fix will not modify existing positions, but will only fix those resources for new updates.
Another solution could be to set the configuration for all models which use acts_as_list to top_of_list: 0 which could be an alternative solution which fixes this issue from re-occurring in the first place.
The Code Change
acts_as_listwhich uses to store the data using ActiveRecord based on indexes.
- Link to commit on Github