Skip to content

Commit

Permalink
Refactoring on issue #64
Browse files Browse the repository at this point in the history
  • Loading branch information
nyxoop2 committed Mar 28, 2023
1 parent 93266af commit 02df49b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/controllers/reviews_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ class ReviewsController < ApplicationController

def create
@game = Game.find(params[:game_id])
@review = @game.reviews.new(review_params)
@review = @game.reviews.build(review_params)
@review.user = current_user
@review.posted_at = Time.now
@review.posted_at = Time.current

if @review.save
@game.update_attribute(:rate_game, @game.calculate_average_rating)
@game.update(rate_game: @game.calculate_average_rating)
redirect_to game_path(@game), notice: "Review enviada com sucesso!"
else
redirect_to game_path(@game), alert: "Não foi possível enviar a review."
redirect_to game_path(@game), alert: "Não foi possível enviar a review."
end
end

Expand Down

0 comments on commit 02df49b

Please sign in to comment.