-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Time- Mair H #32
base: master
Are you sure you want to change the base?
Time- Mair H #32
Conversation
…ta for the Work controller.
… the list of works
… partial rendering to render the edit form to user.
… the works action
…t the relationship between the three models/controllers
…ear on the navigation bar
…media when logged in
… descending order of votes count
…een work and votes respectively
…r and spotlight method
…eflect on media that have been voted on
Media RankerFunctional Requirements: Manual Testing
Major Learning Goals/Code Review
Previous Rails learning, Building Complex Model Logic, DRYing up Rails Code
Testing Rails Apps
Overall Feedback
Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
SummaryThis is very well done you hit the main learning goals using session and models with relationships. You also have good model tests. You are missing most controller tests and have a few bugs (see my comments). However you're doing very well. |
it "can return the page if the user is logged in" do | ||
login() | ||
|
||
get current_user_path |
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.
Just noting this test is failing because the view is using the wrong variable name.
@@ -0,0 +1 @@ | |||
<h2> Current user is <%= @user.name %></h2> |
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.
<h2> Current user is <%= @user.name %></h2> | |
<h2> Current user is <%= @logged_user.name %></h2> |
post "/logout", to: "users#logout", as: "logout" | ||
get "/users/current", to: "users#current", as: "current_user" | ||
|
||
resources :votes, only: [:create] |
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 would suggest nesting this route under works, so that you have the work_id in the route.
belongs_to :user | ||
belongs_to :work | ||
|
||
validates :work_id, uniqueness: { scope: :user_id } |
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.
👍
end | ||
|
||
def self.movies | ||
return Work.where(category: "movie").sort_by { |book| book.votes.count }.reverse |
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.
Just noting these solutions are better using the database functions like .order
or .where
etc. It's much more efficient to let Postgres do the sorting and filtering for you before Rails gets the list. This works at present, but won't scale well.
|
||
if @user.nil? | ||
#New User | ||
@user = User.create(name: params[:user][:name]) |
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.
@user = User.create(name: params[:user][:name]) | |
@user = User.create(username: params[:user][:name]) |
def find_work | ||
@work = Work.find_by(id: params[:id]) | ||
if @work.nil? | ||
head :not_found |
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 strongly suggest you use a redirect instead of head
because it's a bad user experience to present the user with a blank white screen.
require "test_helper" | ||
|
||
describe HomepagesController do | ||
# it "does a thing" do |
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.
Just noting no tests here.
require "test_helper" | ||
|
||
describe VotesController do | ||
# it "does a thing" do |
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.
Just noting no tests here.
require "test_helper" | ||
|
||
describe WorksController do | ||
# it "does a thing" do |
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.
Noting no tests here.
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
session
andflash
? What is the difference between them?