-
Notifications
You must be signed in to change notification settings - Fork 42
Phoebe - Ampers #19
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?
Phoebe - Ampers #19
Conversation
Media RankerWhat We're Looking For
|
|
|
||
| resources :users, only: [:index, :show] | ||
|
|
||
| resources :votes, only: [:new, :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.
Do you need a form or a create action for votes? Wouldn't upvote do just fine?
| session[:user_id] = @user.id | ||
| flash[:success] = "Welcome back #{@user.name}!" | ||
| else | ||
| @user = User.create(user_params) |
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 check to see if create here worked. Check to make sure validations passed!
| belongs_to :work | ||
| belongs_to :user | ||
|
|
||
| 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.
👍
| validates :title, uniqueness: { scope: :category } | ||
| validates :published, format: { with: /\d{4}/ }, numericality: { less_than_or_equal_to: Time.now.strftime("%Y").to_i } | ||
|
|
||
| def self.make_category_hash |
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 isn't making a hash, but an array instead.
| end | ||
|
|
||
| def self.spotlight | ||
| if Work.all != [] |
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 consider using an ennumerable like max_by or using ActiveRecord's .order method to do this.
or just use sort_by_vote you made below.
| @@ -0,0 +1,38 @@ | |||
| require "test_helper" | |||
|
|
|||
| describe Vote 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.
🥇
| work2.valid?.must_equal true | ||
| end | ||
|
|
||
| it "is not valid when published field is not 4 digit integer <= current year" 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.
🥇
Media Ranker
Congratulations! You're submitting your assignment!
Comprehension Questions
sessionandflash? What is the difference between them?