Skip to content

Instantly share code, notes, and snippets.

@DakotaLMartinez
Last active November 7, 2020 19:25
Show Gist options
  • Save DakotaLMartinez/4ecb0693c56b5eed67ed76d04f63f1d5 to your computer and use it in GitHub Desktop.
Save DakotaLMartinez/4ecb0693c56b5eed67ed76d04f63f1d5 to your computer and use it in GitHub Desktop.
Rails Project Planning

What is the Many to many relationship and how is it used?

What is the User Submittable attribute on the join model?

What Validations do we need?

How do users fit into the application? How are they related to the other models?

What are our Nested Routes? (We need a nested new route and either a nested index or nested show route)

Do we have Non Nested Versions of those nested routes?

What Scope Method(s) do we have and how are they used?

What does the schema for our app look like?

# table migration for: examples 
# t.string :name
# t.string :etc…
class Example 
	# relationships

	# validations 

	# user submittable attributes (if this is a join model)

	# scope_methods (if any)


end

Project Examples to flesh out:

  • Doctor, Patient and Appointment
  • User, Project, Task
  • Project, Programmer, Assignment
  • Recipe, Ingredient, RecipeIngredient
  • User, Exercise, ExerciseLog
  • User, Topic, Interest
  • User, Medication, Prescription
  • User, Movie, Review
  • Dancer, DanceClass, Enrollments
  • Character, Motivation, Alignment
@ty-raino
Copy link

ty-raino commented Nov 6, 2020

What is the Many to many relationship and how is it used?

Users -< Reviews >- Games

What is the User Submittable attribute on the join model?

  • Rating
  • Content

What Validations do we need?

Users

  • Username
  • Email
  • Password

Reviews

  • Rating
  • Content

Comments

  • Content

Games

  • Title

How do users fit into the application? How are they related to the other models?

Users can:

  • Review games
  • Add games
  • Comment on other user's reviews
  • Upvote or Downvote other user's reviews (maybe)

Relationships:

  • User has many Reviews
  • User has many Comments
  • User has many Votes
  • User has many Games through Reviews

What are our Nested Routes? (We need a nested new route and either a nested index or nested show route)

games/game_id/reviews => to view all of the reviews made for that specific game
(to be populated...)

Do we have Non Nested Versions of those nested routes?

(to be populated...)

What Scope Method(s) do we have and how are they used?

(to be populated...)

What does the schema for our app look like?

# table migration for: users 
# t.string :username
# t.string :email
# t.string :password_digest

class Users 
	# relationships
	has_many :reviews
	has_many :comments
	has_many :votes
	has_many :games, through: :reviews
	# validations 
	validations :username, presence: true, uniqueness: true
	validations :email, presence: true, uniqueness: true, 
	# scope_methods (if any)
	(to be populated...)
end
# table migration for: reviews 
# t.integer :user_id
# t.integer :game_id
# t.string :rating
# t.string :content

class Reviews 
	# relationships
	belongs_to :user
	belongs_to :game
	# validations 
	validates :rating, presence: true
	validates :rating, :inclusion => { :in => 1..5, :message => " should be between 1 to 5" }
	validates :content, presence: true, length: { maximum: 130 }
	# user submittable attributes (if this is a join model)
	Rating and Content
	# scope_methods (if any)
	(to be populated...)
end
# table migration for: comments 
# t.integer :user_id
# t.integer :review_id
# t.string :content
class Comments 
	# relationships
	belongs_to :users
	belongs_to :reviews
	# validations 
	validates :content, presence: true, length: { maximum: 50 }
end
# table migration for: games 
# t.string :title
class Games 
	# relationships
	has_many :reviews
	has_many :users, through: :reviews
	# validations 
	validates :title, presence: true, uniqueness: true
	validates :title, length: { maximum: 35 }
	validates :is_title_case (custom validation coming soon)
	# scope_methods (if any)
	(to be populated...)
end

Project Examples to flesh out:

  • Doctor, Patient and Appointment
  • User, Project, Task
  • Project, Programmer, Assignment
  • Recipe, Ingredient, RecipeIngredient
  • User, Exercise, ExerciseLog
  • User, Topic, Interest
  • User, Medication, Prescription
  • User, Movie, Review
  • Dancer, DanceClass, Enrollments
  • Character, Motivation, Alignment

@HopperMCS
Copy link

HopperMCS commented Nov 7, 2020

@DakotaLMartinez please review, I've started it but need help finishing/making sure this even works to begin with

What is the Many to many relationship and how is it used?

Users <> Libraries through Performance Ratings
library.users && user.libraries - not created, just rated

What is the User Submittable attribute on the join model?

  • Performace Rating

What Validations do we need?

  • Users

    • Username, presence uniq
    • Email - presence, uniq
    • Password - length, presence
  • Libraries

    • Name
    • language_id
    • Link to source
  • Language

    • Name
    • Purpose
    • Compiled/Scripted?
    • Turing complete?
  • Performance Rating

    • Rating
    • Commentary
    • belongs to user, user_id
    • belongs to libraires, library_id

How do users fit into the application? How are they related to the other models?

  • Users can:
    • Add languages
    • Add libraries
    • Add performance ratings to libraries

What are our Nested Routes? (We need a nested new route and either a nested index or nested show route)

languages/language_id/libraries - nested index - shows libraries specific to language_id
languages/language_id/libraries/new - nested new - form to create lib with lang preset

Do we have Non Nested Versions of those nested routes?

/libraries/ - shows all libraries
/libraries/new - form to create lib without preset lang

What Scope Method(s) do we have and how are they used?

  • order by psoitive/negative
  • order by created_at

What does the schema for our app look like?

# table migration for: examples 
# t.string :name
# t.string :etc…
class Example 
	# relationships

	# validations 

	# user submittable attributes (if this is a join model)

	# scope_methods (if any)


end

Project Examples to flesh out:

Doctor, Patient and Appointment
User, Project, Task
Project, Programmer, Assignment
Recipe, Ingredient, RecipeIngredient
User, Exercise, ExerciseLog
User, Topic, Interest
User, Medication, Prescription
User, Movie, Review
Dancer, DanceClass, Enrollments
Character, Motivation, Alignment

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