<commit_before>class ReviewsController < ApplicationController

	def create
		@review = Review.new(review_params)
		@review.venue_id = params[:venue_id]
		venue = Venue.find_by(id: params[:venue_id])
		@review.user_id = current_user.id
		vibes = Vibe.find(params[:review][:vibes]) if params[:review][:vibes]
		if @review.save && request.xhr?
			@review.vibes = vibes if vibes
			render partial: 'reviews/show', locals: { review: @review }
			@review = Review.new(review_params)
			@current_rating = venue.avg_rating
		elsif @review.save
			@review.vibes = vibes if vibes
			redirect_to venue_path(venue)
		else
			@errors = @review.errors.full_messages
			render partial: 'reviews/new'
		end
	end

	private
	def review_params
		params.require(:review).permit(:content, :rating, :week, :venue_id)
	end

end<commit_msg>define more instance variables to render new form on failed review submission<commit_after>class ReviewsController < ApplicationController

	def create
		@review = Review.new(review_params)
		@review.venue_id = params[:venue_id]
		venue = Venue.find_by(id: params[:venue_id])
		@review.user_id = current_user.id
		vibes = Vibe.find(params[:review][:vibes]) if params[:review][:vibes]
		if @review.save && request.xhr?
			@review.vibes = vibes if vibes
			render partial: 'reviews/show', locals: { review: @review }
			@review = Review.new(review_params)
			@current_rating = venue.avg_rating
		elsif @review.save
			@review.vibes = vibes if vibes
			redirect_to venue_path(venue)
		else
			@errors = @review.errors.full_messages
			@venue = venue
			@vibes = Vibe.all
			render partial: 'reviews/new'
		end
	end

	private
	def review_params
		params.require(:review).permit(:content, :rating, :week, :venue_id)
	end

end
{'fraction_non_alphanumeric': 0.1180195739781232, 'fraction_numerical': 0.0, 'mean_word_length': 4.552715654952077, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1554211', 'n_tokens_mistral': 667, 'n_tokens_neox': 606, 'n_words': 134}