This change introduces polymorphic comments, allowing you to comment on Photos, Plantings, Harvests, and Activities, in addition to Posts.
Key changes include:
- **Comment Model:**
- Made `Comment.commentable` a polymorphic association.
- Added a data migration to move existing post comments to the new structure.
- Updated notification creation logic for polymorphic commentables.
- **CommentsController:**
- Refactored to handle various commentable types using a `find_commentable` method.
- **Ability Model:**
- Updated permissions for comment creation, editing (author/admin), and deletion (author/commentable owner/admin).
- **Routes:**
- Added nested comment routes for Photos, Plantings, Harvests, Activities, and Posts using a `commentable` concern with shallow routes.
- **Views:**
- Created generic partials for comment forms (`_form.html.haml`) and display (`_comment.html.haml`, `_comments.html.haml`).
- Integrated these partials into the show pages of all commentable types.
- Updated `comments/new` and `comments/edit` views to be generic.
- Relevant parent controller `show` actions now eager-load comments.
- **Testing:**
- Added extensive model, controller (using shared examples), and feature tests to cover the new polymorphic comment functionality, including permissions and UI interactions for all commentable types.
- Updated and created factories as needed.
This fulfills the issue requirements for adding comments to multiple resource types with appropriate permissions.
🌱 Growstuff
Welcome to the Growstuff project.
You can find our app at https://www.growstuff.org
Growstuff is an open source/open data project for food gardeners. We crowdsource information on what our members are growing and harvesting, aggregate it, and make it available as open data via our API.
Growstuff was founded in 2012 and has been built by dozens of contributors. We are an inclusive, welcoming project, and encourage participation from people of all backgrounds and skill levels.
Want to contribute?
Don't ask to ask, the best way to get started is to fork the project, start a codespace and get hacking. Dive on in and submit your PRs.
Important links
For coders
Growstuff is built in Ruby on Rails and also uses JavaScript for frontend features. We welcome contributions -- see CONTRIBUTING for details.
- To set up your development environment, see Getting started.
- You may also be interested in our API.
For designers, writers, researchers, data wranglers, and other contributors
There are heaps of ways to get involved and contribute no matter what your skills and interests.
You might like to check out:
- The New Contributor Guide page on our wiki, which has lots of detail for different areas
Here on Github, you might find these useful:
- Github Project Board has stories in "ready" that can be worked on.
- needs: design - tasks requiring high-level design
- needs: visual design - tasks requiring visual/graphical design
- needs: documentation
- needs: data - tasks requiring data entry, data design, data import, or similar
- curated:beginner - tasks that are ideal for beginner programmers or people new to the project
Feel free to comment on any of the issues on Github.
Contact
For more information about this project, contact info@growstuff.org.
Security Issues: If you find an authorization bypass or data breach, please contact our maintainers directly at maintainers@growstuff.org.