Files
growstuff/app/controllers/crop_dismissals_controller.rb
T
Brenda Wallace ef06bab74f Add crop suggestions feature and dashboard enhancements
- Introduced crop suggestions functionality allowing users to receive tailored crop recommendations based on their location and preferences.
- Implemented the ability for users to dismiss specific crop suggestions, preventing them from receiving recommendations for crops they are not interested in.
- Added a location picker for users to set their gardening location, enhancing the accuracy of crop suggestions.
- Enhanced the dashboard to display relevant statistics, including plantings and harvests, with comparisons to previous years.
- Created new views and partials for displaying statistics, crop suggestions, and user interactions on the dashboard.
- Updated routes to accommodate new features related to crop suggestions and member locations.
- Added migrations for new database tables and columns to support crop dismissal and suggestion preferences.
- Developed tests for the new features, ensuring functionality and user experience are maintained.
2026-10-12 19:12:18 +13:00

20 lines
620 B
Ruby

# frozen_string_literal: true
# "Not for me" on a suggested crop: the home page stops suggesting it, until
# they ask for their hidden suggestions back.
class CropDismissalsController < ApplicationController
skip_authorize_resource
before_action :authenticate_member!
def create
crop = Crop.approved.find(params.require(:crop_id))
current_member.crop_dismissals.find_or_create_by!(crop:)
redirect_back_or_to root_path, notice: t('.dismissed', crop: crop.name)
end
def destroy_all
current_member.crop_dismissals.destroy_all
redirect_back_or_to root_path, notice: t('.restored')
end
end