-
Notifications
You must be signed in to change notification settings - Fork 42
Victoria Garcia : Ampers : 1 hour late #42
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
base: master
Are you sure you want to change the base?
Conversation
…ry much subject to change.
…ch subject to change.
…to the params methods in the users and works controllers to accommodate the actual fields in the various tables.
…chanism in place.
… Works is officially functional; YAMLs for Vote and User are not yet tested, but written
…re written and passing.
…hing is working yet, however.
…ing up is now fixed.
…ifications are still needed.
…breaking up login methods in Session to allow appropriate redirection.
… I only have six hours left.
… have to be both the last commit and the last branch.
Media RankerWhat We're Looking For
|
|
|
||
| resources :users, except: [:edit, :update] | ||
|
|
||
| resources :votes, except: [:new, :create, :destroy] |
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.
So people can edit, and update votes? What about index and show?
| <%= link_to "See all Users", users_path, class: 'button' %> | ||
| <%= link_to "Back to Media List", works_path, class: 'button' %> | ||
|
|
||
| <h1><%= Work.find_by(title: "Dogzilla").title %></h1> |
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.
This is causing the site to crash. Did you leave it in by accident?
|
|
||
| validate :one_vote_per_user_per_work | ||
|
|
||
| def one_vote_per_user_per_work |
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.
Neat custom validation. You can also do something similar with uniqueness and scope like in the rails api guide
| end | ||
|
|
||
| def self.report_works_voted_for(id_for_user) | ||
| @upvoted_works = self.where(user_id: id_for_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.
I don't think this method is really very useful as any Work instance has a votes method.
| validates :title, length: { in: 1..35 } | ||
|
|
||
|
|
||
| def self.works_with_vote_tallies |
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.
These methods seems overly complicated. Couldn't you do a method to get the works in order by the number of votes with:
works = Work.all.to_a
return works.sort_by { |work| -work.total_votes }And you can always get the vote tally for a work with: work.votes.count
| end | ||
|
|
||
|
|
||
| it "contains elements in which index position 1 is the correct tally of votes for the element at index position 0" 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.
missing test?
| work.valid?.must_equal false | ||
| end | ||
|
|
||
| describe "works_with_vote_tallies" 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.
You should also test this method when no votes have been issued for any work, and when there are no works period.
|
|
||
| describe "works_ordered_by_popularity" do | ||
|
|
||
| it "returns an array" 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.
Missing tests
|
|
||
| def show | ||
| id = params[:id] | ||
| @work = Work.find(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.
Hmm a filter would go swell here!
| flash[:alert] = @vote.errors | ||
| end | ||
| end | ||
| redirect_to work_path(params[:work_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.
Maybe redirect_back would be better here.
NOTE: THIS IS AN UPDATED PULL REQUEST. I spotted several major bugs after deployment (the worst having to do with a problem on form for Work, and a couple of other having to do with bad redirects, plus one to do with an improper tag on the Work show page, and one to do with a raise left in the vote model.) I fixed them as of 4/15.
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
sessionandflash? What is the difference between them?