wikitongues / poly

Open source, modern software to share and learn every language in the world.
https://poly.wikitongues.org
GNU General Public License v3.0
80 stars 19 forks source link

Sort favorites by time favorited #269

Closed smrohrer closed 7 years ago

FredericoAndrade commented 7 years ago

Hi Scott! Awesome work getting started on all this stuff. I've gone ahead and merged the bootbox alert branch and deployed it into master. I'm afraid this branch seems to have some issues outlined below:

ActiveRecord::RecordNotFound in DashboardController#index Couldn't find Book with 'id'=510

image

Where do you define fav_book? I can't seem to find mention of it anywhere outside of this controller.

Thanks!

smrohrer commented 7 years ago

Hi Freddie,

Sorry about that, I am still not entirely familiar with the Ruby map syntax so I may have made a mistake. What I was trying to do was get all FavoriteBook records belonging to @user, sort them by created_at, and find the corresponding Book record for each record in the results. fav_book is just the name I'm assigning to each record in the do loop.

It looks like the error you had was that there was a FavoriteBook record corresponding to a Book that was not in the database. I reproduced the error by adding a book to favorites and then deleting the book.

I added a rescue block that will remove the FavoriteBook record if the Book is not found, and pushed to the branch for this issue. This prevents the error, but the favorite book list does not appear correctly until the page is refreshed. We can talk about how to fix that on Sunday if I do not figure it out by then.

Thanks, Scott

On Jul 25, 2017, at 1:49 PM, Frederico Andrade notifications@github.com wrote:

Hi Scott! Awesome work getting started on all this stuff. I've gone ahead and merged the bootbox alert branch and deployed it into master. I'm afraid this branch seems to have some issues outlined below:

ActiveRecord::RecordNotFound in DashboardController#index Couldn't find Book with 'id'=510

https://user-images.githubusercontent.com/2080065/28545662-e47dee6a-7095-11e7-8818-d2c0f37e5c34.png Where do you define fav_book? I can't seem to find mention of it anywhere outside of this controller.

Thanks!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wikitongues/poly/pull/269#issuecomment-317815259, or mute the thread https://github.com/notifications/unsubscribe-auth/AFIFHmYtzU8Y0fr2GkLaoMmSAq6n0bLjks5sRiqagaJpZM4OgQUq.

smrohrer commented 7 years ago

I think I fixed the issue by destroying all corresponding FavoriteBook records from the destroy method in books_controller. Now when I delete a book which I favorited, it returns me to the dashboard with the favorites list properly updated.

FredericoAndrade commented 7 years ago

@smrohrer thank you so much for your fixes! Merged and deployed!