This repository was archived by the owner on Nov 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/fifth assignment #5
Open
MrPranklin
wants to merge
26
commits into
master
Choose a base branch
from
feature/fifth-assignment
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
ae727ac
Initial commit to branch
MrPranklin 78b7a4d
Installed annotate gem, annotated
MrPranklin 76e9412
Remove excess controller
MrPranklin b9d84b6
Created SubReddit model, migrated
MrPranklin fd96cd6
Added columns to posts database
MrPranklin 0d8d9e3
Change drop_authors, add create_users
MrPranklin 0df4306
ocnvert comment associations to references'
MrPranklin 80dc0fb
Finish tutorial
MrPranklin 5f062cb
Add things missed in chapter, spelling
MrPranklin 28880e9
FInished 6th task in 5th assignment
MrPranklin 9feae30
Add upvote model, important changes
MrPranklin f14a7c1
Add associations
MrPranklin 5d29943
Migrated all tasks, annotated
MrPranklin a818100
Destroy authors, create user controller and rest
MrPranklin d5a17fd
Add title and subreddit print
MrPranklin b14bd2e
Remove old, wrong solutions
MrPranklin 2a29c9d
Tried to change input for post creation
MrPranklin 957b520
Really dumb way of refactoring
MrPranklin df5f665
Add mock routes for users
MrPranklin 5a4f6c9
Configure user routes, views and controller
MrPranklin 485ada5
Added message to post show view
MrPranklin 417b21c
Added print to views
MrPranklin 2b173f9
Add newly added columns to print
MrPranklin fd2c1e4
Removed empty line
MrPranklin 98bd2c7
Merge branch 'master' into feature/fifth-assignment
MrPranklin 0a23b16
Change belongs_to :user to :owner
MrPranklin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
app/assets/stylesheets/authors.scss → app/assets/stylesheets/users.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| // Place all the styles related to the Authors controller here. | ||
| // Place all the styles related to the users controller here. | ||
| // They will automatically be included in application.css. | ||
| // You can use Sass (SCSS) here: http://sass-lang.com/ |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class UsersController < ApplicationController | ||
| def index | ||
| @users = User.all | ||
| end | ||
|
|
||
| def show | ||
| @user = User.find_by( id: params[:id] ) | ||
| end | ||
|
|
||
| def new | ||
| @user = User.new | ||
| end | ||
| end |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| module UsersHelper | ||
| end |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,18 @@ | ||
| # == Schema Information | ||
| # | ||
| # Table name: comments | ||
| # | ||
| # id :integer not null, primary key | ||
| # post_id :integer | ||
| # author_id :integer | ||
| # content :text | ||
| # created_at :datetime not null | ||
| # updated_at :datetime not null | ||
| # | ||
|
|
||
| class Comment < ApplicationRecord | ||
| belongs_to :post | ||
| belongs_to :author, class_name: 'User' | ||
|
|
||
| validates :content, presence: true, length: { minimum: 2 } | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,24 @@ | ||
| # frozen_string_literal: true | ||
| # == Schema Information | ||
| # | ||
| # Table name: posts | ||
| # | ||
| # id :integer not null, primary key | ||
| # author_id :integer not null | ||
| # content :text | ||
| # published :boolean | ||
| # created_at :datetime not null | ||
| # updated_at :datetime not null | ||
| # title :string default(""), not null | ||
| # sub_reddit_id :integer | ||
| # | ||
|
|
||
| class Post < ApplicationRecord | ||
| has_many :comments | ||
| has_many :upvotes | ||
| belongs_to :user | ||
| belongs_to :sub_reddits | ||
|
|
||
| validates :title, presence: true, uniqueness: true | ||
| validates :sub_reddit_id, presence: true | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # == Schema Information | ||
| # | ||
| # Table name: sub_reddits | ||
| # | ||
| # id :integer not null, primary key | ||
| # title :string not null | ||
| # description :text not null | ||
| # private :boolean default(FALSE), not null | ||
| # created_at :datetime not null | ||
| # updated_at :datetime not null | ||
| # owner_id :integer | ||
| # | ||
|
|
||
| class SubReddit < ApplicationRecord | ||
| belongs_to :user | ||
| has_many :posts | ||
|
|
||
| validates :title, presence: true, uniqueness: true | ||
| validates :owner, presence: true | ||
| validates :description, presence: true | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # == Schema Information | ||
| # | ||
| # Table name: upvotes | ||
| # | ||
| # id :integer not null, primary key | ||
| # creator :string not null | ||
| # post :string not null | ||
| # created_at :datetime not null | ||
| # updated_at :datetime not null | ||
| # creator_id :integer | ||
| # post_id :integer | ||
| # | ||
|
|
||
| class Upvote < ApplicationRecord | ||
| belongs_to :user | ||
| belongs_to :post | ||
|
|
||
| validates :post, presence: true | ||
| validates :creator, uniqueness: true, presence: true | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # == Schema Information | ||
| # | ||
| # Table name: users | ||
| # | ||
| # id :integer not null, primary key | ||
| # email :string not null | ||
| # username :string not null | ||
| # created_at :datetime not null | ||
| # updated_at :datetime not null | ||
| # | ||
|
|
||
| class User < ApplicationRecord | ||
| has_many :comments, foreign_key: 'author_id' | ||
| has_many :sub_reddits | ||
| has_many :posts | ||
| has_many :upvotes | ||
|
|
||
| validates :email, uniqueness: { scope: :username } , presence: true | ||
| end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,5 +3,3 @@ | |
| <%= render 'form', comment: @comment %> | ||
|
|
||
| <%= link_to 'Back', comments_path %> | ||
|
|
||
| <h2>Solve captcha!</h2> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the user owner?
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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'There was a problem hiding this comment.
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?