Skip to content

Conversation

@olenaniemova
Copy link
Collaborator

Task 1: Display User Info on Member Dashboard
Currently, after signing in, the User will see a "dashboard" screen. Update that dashboard so it shows their email, created at, and updated at instead of "...".

Task 2: Store and Display All Login Timestamps
Currently, the member dashboard only shows the time of their most recent login. Make the necessary changes to the database, models, controllers, and views so we can store and display when every login happens for a user.

Task 3: Product Detail Page + Categories
Display a list of all the categories each product belongs to, and link to them.

Task 4: "Favorite" a Product
If the current user is signed in, show a heart icon which the user can click to "heart" the product, and click again to remove the product from their favorites.
On the "Members Dashboard" view, add a list of links to their favorite products.

Task 5: Only show "is_active=true" Products
On the Category page, only show "active" products.
If a product with "is_active=false" is requested, return a 404 response.
Remove "is_active=false" products from the Members Dashboard "favorite products" list.

Results
image

Product page (added categories, add to favorite)
image

image

404 page when the product is not active
image

Comment on lines +8 to +11
execute <<-SQL
INSERT INTO user_logins (user_id, login_at)
SELECT id, last_login_at FROM users;
SQL
Copy link
Collaborator Author

@olenaniemova olenaniemova Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, it is not the best solution to put raw SQL in the migration to migrate data from one table to another. But it works in this small project.
For real projects which have a big codebase and database, in such cases, I would use a data-migrate gem or rake task to create separate migration for data. The development should look like this:

  1. Create migration for the new table, create migration for data, change code to save data into the new table
  2. Test, release to prod, and check that all work well
  3. Create migration to remove the old column
  4. Test, release changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants