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.
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> No newline at end of file | |||
There was a problem hiding this comment.
| <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.
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 } |
| end | ||
|
|
||
| def self.movies | ||
| return Work.where(category: "movie").sort_by { |book| book.votes.count }.reverse |
There was a problem hiding this comment.
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.
| @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.
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 |
| require "test_helper" | ||
|
|
||
| describe VotesController do | ||
| # it "does a thing" do |
| require "test_helper" | ||
|
|
||
| describe WorksController do | ||
| # it "does a thing" do |
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
sessionandflash? What is the difference between them?