Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Conversation

@MrPranklin
Copy link
Owner

Problems I'm not sure if I was supposed to solve now, as it is not explicitly specified:

  • unable to add new comments (not to another post, just plain comments) because captcha is required, but it works through posts view
  • unable to add new users, posts and comments through web page (using old way or simple form)

Problems I don't know how to solve (but it makes sense that it should work, although I'm not sure it has to):

  • database entries for comments and posts not showing up (users show up normally) when added through Rails console)
  • none of the primary keys are added automatically
  • none of the timestamps are added automatically
  • there may be a few more that I forgot

I'm pretty sure that most of these problems have obvious solutions, it's just that I don't see them.

Assignment

  • Create a SubReddit model
    • it has a unique title, no matter the capitalization, that can't be nil
    • it has an owner, which is a reference to the user, which can't be nil
    • it has a description which can't be nil
  • create appropriate validations on the model
  • Drop the Author model
  • Create the User model
    • it has an email that's unique and can't be nil
    • it has a username that's unique and can't be nil
    • create appropriate validations on the model
  • Add a title column to the Post model
    • it has to be unique
    • it can't be nil
    • it's default value is '' (empty string)
    • create appropriate validations on the model
  • Change an author_id column on the Post model that's a reference to an User
    • it can't be nil
    • create appropriate validations on the model
  • Create an sub_reddit_id column on the Post model that's a reference to a SubReddit
    • it can't be nil
    • create appropriate validations on the model
  • Create an Upvote model
    • it has a creator reference to an User, that can't be nil
    • it has a post reference to a Post, that can't be nil
    • each Upvote has to be unique for each post regarding a user (e.g. each user can have only one upvote for a post)
    • create appropriate validations on the model
  • Create associations on the User model
    • For Upvotes
    • For Posts
    • For SubReddits
  • Create associations on Post
    • For SubReddit
    • For User
  • Create associations on SubReddit
    • For User
  • Create associations on Upvote
    • For Post
    • For User
  • Migrate all changes
  • Run Annotate
  • Delete the author's views, routes, and controller
  • Create routes, views and a controller for users
  • Update all show actions to show some field of their associated records

@MrPranklin MrPranklin requested a review from fsuste January 14, 2019 20:23
#

class SubReddit < ApplicationRecord
belongs_to :user
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the user owner?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I thought that a SubReddit must have been created by someone, so the creator (a User) would be it's owner. If that's not the case, was the expected solution that every SubReddit owns many Users (a.k.a. has subscribers) and every User belongs to many SubReddits (a.k.a. is subscribed to many)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure, but this by default makes rails look for user_id. If you want to access your user as an "owner" method, you need specify it like belongs_to :owner, class_name: 'User'

Copy link
Owner Author

Choose a reason for hiding this comment

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

Are any database changes necessary for this or is that it?

@fsuste
Copy link
Collaborator

fsuste commented Jan 16, 2019

Some of the features you are using don't work in SQLite database. For now let's keep it in SQLite, but we will probably migrate to postgreSQL in future assignments.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants