How do you create a wishlist?

How do you create a wishlist? Could you give me some starting points (guidelines) of how I can get started please? Thank you in advance!

Posted over 4 years ago by Joseph
Posted over 4 years ago by Alex Yang

Hmm...obviously a lot depends on context and how you want it to work. But let's say you wanted to extend our Etsydemo course with a product wishlist. A good place to start is to think about it from a database perspective. We would need a new Wishlist database, where each row corresponds to a single product that's been 'favorited' by a single user. So we need two columns: listing_id and user_id.

Once our database is set up, we need to figure out how we'll integrate this into our existing site. We'll need to set up a new Wishlists Controller which will give us the functionality, allowing us to favorite a listing, un-favorite a listing, edit a wishlist, etc. If you're just getting started with Rails, best to use a 'rails generate ...' command to create a default controller or model yours off one of your existing controllers.

Finally, we need to set up our view pages. We may need to create new view pages (e.g. for editing a wishlist), but mostly we'll just need to add buttons for favoriting (and unfavoriting) a product from our existing pages (e.g. the Listing Show page). We'll need to connect those buttons to the corresponding actions in our controller and we should be all set.

All of this is pretty generalized, so I hope you understand the basic approach to use in thinking about how to add a new feature like this one. Hope it helps!