Garden-Managers / garden_manager_fe

1 stars 1 forks source link

Plant duplicates #17

Open ParkerLockhart opened 2 years ago

ParkerLockhart commented 2 years ago

Expected behavior:

To not be able to add a plant to user collection if already added.

Actual behavior:

User can continue to add the same plant to collection repeatedly.

Steps to reproduce the behavior:

While logged in user, navigate to plant library. Click 'add to my plants' on a plant. You will receive confirmation that it has been added (check user dashboard under "My Plants" section to confirm.) Click 'add to my plants' on the same plant again, and you will receive confirmation again. Now, the "My Plants" section on dashboard will have two records of that plant displayed.

ParkerLockhart commented 2 years ago

Idea: find a way to use @user_plants.include?(@plant) to compare and show "In my collection" badge instead of 'add to my plants' button

@Garden-Managers/be maybe we can use some kind of validations or db constraints to prevent duplicate user/plant join table records from being created?