Update find method
This commit is contained in:
@ -12,7 +12,7 @@ class LaExercisesChannel < ApplicationCable::Channel
|
||||
private
|
||||
|
||||
def specific_channel
|
||||
reject unless StudyGroupPolicy.new(current_user, StudyGroup.find_by(id: params[:study_group_id])).stream_la?
|
||||
reject unless StudyGroupPolicy.new(current_user, StudyGroup.find(params[:study_group_id])).stream_la?
|
||||
"la_exercises_#{params[:exercise_id]}_channel_study_group_#{params[:study_group_id]}"
|
||||
end
|
||||
end
|
||||
|
@ -41,7 +41,7 @@ module CodeOcean
|
||||
end
|
||||
|
||||
def destroy
|
||||
@file = CodeOcean::File.find_by(id: params[:id])
|
||||
@file = CodeOcean::File.find(params[:id])
|
||||
authorize!
|
||||
destroy_and_respond(object: @file, path: @file.context)
|
||||
end
|
||||
|
@ -43,7 +43,7 @@ class CodeharborLinksController < ApplicationController
|
||||
end
|
||||
|
||||
def set_codeharbor_link
|
||||
@codeharbor_link = CodeharborLink.find_by(id: params[:id])
|
||||
@codeharbor_link = CodeharborLink.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -10,7 +10,7 @@ class CommentsController < ApplicationController
|
||||
|
||||
# GET /comments.json
|
||||
def index
|
||||
file = CodeOcean::File.find_by(id: params[:file_id])
|
||||
file = CodeOcean::File.find(params[:file_id])
|
||||
# there might be no submission yet, so dont use find
|
||||
submission = Submission.find_by(id: file.context_id)
|
||||
if submission
|
||||
@ -38,7 +38,7 @@ class CommentsController < ApplicationController
|
||||
|
||||
if @comment.save
|
||||
if comment_params[:request_id]
|
||||
request_for_comment = RequestForComment.find_by(id: comment_params[:request_id])
|
||||
request_for_comment = RequestForComment.find(comment_params[:request_id])
|
||||
send_mail_to_author @comment, request_for_comment
|
||||
send_mail_to_subscribers @comment, request_for_comment
|
||||
end
|
||||
@ -71,7 +71,7 @@ class CommentsController < ApplicationController
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_comment
|
||||
@comment = Comment.find_by(id: params[:id])
|
||||
@comment = Comment.find(params[:id])
|
||||
end
|
||||
|
||||
def comment_params_for_update
|
||||
|
@ -90,11 +90,11 @@ class CommunitySolutionsController < ApplicationController
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_community_solution
|
||||
@community_solution = CommunitySolution.find_by(id: params[:id])
|
||||
@community_solution = CommunitySolution.find(params[:id])
|
||||
end
|
||||
|
||||
def set_community_solution_lock
|
||||
@community_solution_lock = CommunitySolutionLock.find_by(id: params[:lock_id])
|
||||
@community_solution_lock = CommunitySolutionLock.find(params[:lock_id])
|
||||
end
|
||||
|
||||
def set_exercise_and_submission
|
||||
|
@ -38,7 +38,7 @@ class ConsumersController < ApplicationController
|
||||
end
|
||||
|
||||
def set_consumer
|
||||
@consumer = Consumer.find_by(id: params[:id])
|
||||
@consumer = Consumer.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
private :set_consumer
|
||||
|
@ -86,7 +86,7 @@ class ErrorTemplateAttributesController < ApplicationController
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_error_template_attribute
|
||||
@error_template_attribute = ErrorTemplateAttribute.find_by(id: params[:id])
|
||||
@error_template_attribute = ErrorTemplateAttribute.find(params[:id])
|
||||
end
|
||||
|
||||
def error_template_attribute_params
|
||||
|
@ -77,7 +77,7 @@ class ErrorTemplatesController < ApplicationController
|
||||
|
||||
def add_attribute
|
||||
authorize!
|
||||
@error_template.error_template_attributes << ErrorTemplateAttribute.find_by(id: params[:error_template_attribute_id])
|
||||
@error_template.error_template_attributes << ErrorTemplateAttribute.find(params[:error_template_attribute_id])
|
||||
respond_to do |format|
|
||||
format.html { redirect_to @error_template }
|
||||
format.json { head :no_content }
|
||||
@ -86,7 +86,7 @@ class ErrorTemplatesController < ApplicationController
|
||||
|
||||
def remove_attribute
|
||||
authorize!
|
||||
@error_template.error_template_attributes.delete(ErrorTemplateAttribute.find_by(id: params[:error_template_attribute_id]))
|
||||
@error_template.error_template_attributes.delete(ErrorTemplateAttribute.find(params[:error_template_attribute_id]))
|
||||
respond_to do |format|
|
||||
format.html { redirect_to @error_template }
|
||||
format.json { head :no_content }
|
||||
@ -97,7 +97,7 @@ class ErrorTemplatesController < ApplicationController
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_error_template
|
||||
@error_template = ErrorTemplate.find_by(id: params[:id])
|
||||
@error_template = ErrorTemplate.find(params[:id])
|
||||
end
|
||||
|
||||
def error_template_params
|
||||
|
@ -141,7 +141,7 @@ class ExecutionEnvironmentsController < ApplicationController
|
||||
private :set_docker_images
|
||||
|
||||
def set_execution_environment
|
||||
@execution_environment = ExecutionEnvironment.find_by(id: params[:id])
|
||||
@execution_environment = ExecutionEnvironment.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
private :set_execution_environment
|
||||
|
@ -41,7 +41,7 @@ class ExerciseCollectionsController < ApplicationController
|
||||
private
|
||||
|
||||
def set_exercise_collection
|
||||
@exercise_collection = ExerciseCollection.find_by(id: params[:id])
|
||||
@exercise_collection = ExerciseCollection.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -40,7 +40,7 @@ class ExercisesController < ApplicationController
|
||||
@exercises = Exercise.all
|
||||
authorize!
|
||||
@exercises = params[:exercises].values.map do |exercise_params|
|
||||
exercise = Exercise.find_by(id: exercise_params.delete(:id))
|
||||
exercise = Exercise.find(exercise_params.delete(:id))
|
||||
exercise.update(exercise_params)
|
||||
exercise
|
||||
end
|
||||
@ -439,7 +439,7 @@ class ExercisesController < ApplicationController
|
||||
private :set_execution_environments
|
||||
|
||||
def set_exercise_and_authorize
|
||||
@exercise = Exercise.find_by(id: params[:id])
|
||||
@exercise = Exercise.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
|
||||
@ -447,7 +447,7 @@ class ExercisesController < ApplicationController
|
||||
|
||||
def set_external_user_and_authorize
|
||||
if params[:external_user_id]
|
||||
@external_user = ExternalUser.find_by(id: params[:external_user_id])
|
||||
@external_user = ExternalUser.find(params[:external_user_id])
|
||||
authorize!
|
||||
end
|
||||
end
|
||||
|
@ -15,7 +15,7 @@ class ExternalUsersController < ApplicationController
|
||||
end
|
||||
|
||||
def show
|
||||
@user = ExternalUser.find_by(id: params[:id])
|
||||
@user = ExternalUser.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
|
||||
@ -58,7 +58,7 @@ class ExternalUsersController < ApplicationController
|
||||
end
|
||||
|
||||
def statistics
|
||||
@user = ExternalUser.find_by(id: params[:id])
|
||||
@user = ExternalUser.find(params[:id])
|
||||
authorize!
|
||||
|
||||
statistics = {}
|
||||
@ -73,7 +73,7 @@ class ExternalUsersController < ApplicationController
|
||||
end
|
||||
|
||||
def tag_statistics
|
||||
@user = ExternalUser.find_by(id: params[:id])
|
||||
@user = ExternalUser.find(params[:id])
|
||||
authorize!
|
||||
|
||||
statistics = []
|
||||
|
@ -87,7 +87,7 @@ class FileTemplatesController < ApplicationController
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_file_template
|
||||
@file_template = FileTemplate.find_by(id: params[:id])
|
||||
@file_template = FileTemplate.find(params[:id])
|
||||
end
|
||||
|
||||
def file_template_params
|
||||
|
@ -51,7 +51,7 @@ class FileTypesController < ApplicationController
|
||||
private :set_editor_modes
|
||||
|
||||
def set_file_type
|
||||
@file_type = FileType.find_by(id: params[:id])
|
||||
@file_type = FileType.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
private :set_file_type
|
||||
|
@ -127,7 +127,7 @@ class InternalUsersController < ApplicationController
|
||||
private :set_up_password
|
||||
|
||||
def set_user
|
||||
@user = InternalUser.find_by(id: params[:id])
|
||||
@user = InternalUser.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
private :set_user
|
||||
|
@ -24,7 +24,7 @@ class ProxyExercisesController < ApplicationController
|
||||
|
||||
def create
|
||||
myparams = proxy_exercise_params
|
||||
myparams[:exercises] = Exercise.find_by(id: myparams[:exercise_ids].compact_blank)
|
||||
myparams[:exercises] = Exercise.find(myparams[:exercise_ids].compact_blank)
|
||||
@proxy_exercise = ProxyExercise.new(myparams)
|
||||
authorize!
|
||||
|
||||
@ -63,7 +63,7 @@ class ProxyExercisesController < ApplicationController
|
||||
end
|
||||
|
||||
def set_exercise_and_authorize
|
||||
@proxy_exercise = ProxyExercise.find_by(id: params[:id])
|
||||
@proxy_exercise = ProxyExercise.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
private :set_exercise_and_authorize
|
||||
@ -78,7 +78,7 @@ class ProxyExercisesController < ApplicationController
|
||||
|
||||
def update
|
||||
myparams = proxy_exercise_params
|
||||
myparams[:exercises] = Exercise.find_by(id: myparams[:exercise_ids].compact_blank)
|
||||
myparams[:exercises] = Exercise.find(myparams[:exercise_ids].compact_blank)
|
||||
update_and_respond(object: @proxy_exercise, params: myparams)
|
||||
end
|
||||
end
|
||||
|
@ -58,7 +58,7 @@ class RequestForCommentsController < ApplicationController
|
||||
|
||||
# GET /exercises/:id/request_for_comments
|
||||
def rfcs_for_exercise
|
||||
exercise = Exercise.find_by(id: params[:exercise_id])
|
||||
exercise = Exercise.find(params[:exercise_id])
|
||||
@search = RequestForComment
|
||||
.with_last_activity
|
||||
.where(exercise_id: exercise.id)
|
||||
@ -141,7 +141,7 @@ class RequestForCommentsController < ApplicationController
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_request_for_comment
|
||||
@request_for_comment = RequestForComment.find_by(id: params[:id])
|
||||
@request_for_comment = RequestForComment.find(params[:id])
|
||||
end
|
||||
|
||||
def request_for_comment_params
|
||||
@ -154,7 +154,7 @@ class RequestForCommentsController < ApplicationController
|
||||
# The index page requires the grouping of the study groups
|
||||
# The study groups are grouped by the current study group and other study groups of the user
|
||||
def set_study_group_grouping
|
||||
current_study_group = StudyGroup.find_by(id: session[:study_group_id])
|
||||
current_study_group = StudyGroup.find_by(session[:study_group_id])
|
||||
my_study_groups = current_user.study_groups.reject {|group| group == current_study_group }
|
||||
@study_groups_grouping = [[t('request_for_comments.index.study_groups.current'), Array(current_study_group)],
|
||||
[t('request_for_comments.index.study_groups.my'), my_study_groups]]
|
||||
|
@ -42,7 +42,7 @@ class SessionsController < ApplicationController
|
||||
end
|
||||
|
||||
def destroy_through_lti
|
||||
@submission = Submission.find_by(id: params[:submission_id])
|
||||
@submission = Submission.find(params[:submission_id])
|
||||
authorize(@submission, :show?)
|
||||
lti_parameter = LtiParameter.where(external_users_id: @submission.user_id, exercises_id: @submission.exercise_id).last
|
||||
@url = consumer_return_url(build_tool_provider(consumer: @submission.user.consumer, parameters: lti_parameter&.lti_parameters))
|
||||
|
@ -23,7 +23,7 @@ class StudyGroupsController < ApplicationController
|
||||
def update
|
||||
myparams = study_group_params
|
||||
myparams[:external_users] =
|
||||
StudyGroupMembership.find_by(id: myparams[:study_group_membership_ids].compact_blank).map(&:user)
|
||||
StudyGroupMembership.find(myparams[:study_group_membership_ids].compact_blank).map(&:user)
|
||||
myparams.delete(:study_group_membership_ids)
|
||||
update_and_respond(object: @study_group, params: myparams)
|
||||
end
|
||||
@ -38,7 +38,7 @@ class StudyGroupsController < ApplicationController
|
||||
private :study_group_params
|
||||
|
||||
def set_group
|
||||
@study_group = StudyGroup.find_by(id: params[:id])
|
||||
@study_group = StudyGroup.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
private :set_group
|
||||
|
@ -369,7 +369,7 @@ class SubmissionsController < ApplicationController
|
||||
end
|
||||
|
||||
def set_submission
|
||||
@submission = Submission.find_by(id: params[:id])
|
||||
@submission = Submission.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ class SubscriptionsController < ApplicationController
|
||||
# DELETE /subscriptions/1
|
||||
# DELETE /subscriptions/1.json
|
||||
def destroy
|
||||
@subscription = Subscription.find_by(id: params[:id])
|
||||
@subscription = Subscription.find(params[:id])
|
||||
rescue StandardError
|
||||
skip_authorization
|
||||
respond_to do |format|
|
||||
@ -47,7 +47,7 @@ class SubscriptionsController < ApplicationController
|
||||
end
|
||||
|
||||
def set_subscription
|
||||
@subscription = Subscription.find_by(id: params[:id])
|
||||
@subscription = Subscription.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
private :set_subscription
|
||||
|
@ -38,7 +38,7 @@ class TagsController < ApplicationController
|
||||
end
|
||||
|
||||
def set_tag
|
||||
@tag = Tag.find_by(id: params[:id])
|
||||
@tag = Tag.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
private :set_tag
|
||||
|
@ -44,7 +44,7 @@ class TipsController < ApplicationController
|
||||
end
|
||||
|
||||
def set_tip
|
||||
@tip = Tip.find_by(id: params[:id])
|
||||
@tip = Tip.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
private :set_tip
|
||||
|
@ -25,7 +25,7 @@ class UserExerciseFeedbacksController < ApplicationController
|
||||
def create
|
||||
Sentry.set_extras(params: uef_params)
|
||||
|
||||
@exercise = Exercise.find_by(id: uef_params[:exercise_id])
|
||||
@exercise = Exercise.find(uef_params[:exercise_id])
|
||||
rfc = RequestForComment.unsolved.where(exercise_id: @exercise.id, user_id: current_user.id).first
|
||||
submission = begin
|
||||
current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first
|
||||
@ -67,7 +67,7 @@ class UserExerciseFeedbacksController < ApplicationController
|
||||
else
|
||||
params[:user_exercise_feedback][:exercise_id]
|
||||
end
|
||||
@exercise = Exercise.find_by(id: exercise_id)
|
||||
@exercise = Exercise.find(exercise_id)
|
||||
@uef = UserExerciseFeedback.find_or_initialize_by(user: current_user, exercise: @exercise)
|
||||
authorize!
|
||||
end
|
||||
@ -105,7 +105,7 @@ class UserExerciseFeedbacksController < ApplicationController
|
||||
end
|
||||
|
||||
def set_user_exercise_feedback
|
||||
@uef = UserExerciseFeedback.find_by(id: params[:id])
|
||||
@uef = UserExerciseFeedback.find(params[:id])
|
||||
@exercise = @uef.exercise
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user