app/controllers/costumes_controller.rb
# Studio
# Receives data from assign costume form
# POST /costumes/:id/assign
Studio
Receives data from assign costume form
POST /costumes/:id/assign
Studio Receives data from assign costume form POST / costumes / : id / assign
def assign
    @previous_assignment_count = @costume.costume_assignments.count 
    redirect_to_assign_costume_form_if_required_fields_empty and return
    @updated = @costume.update(costume_params)
    redirect_to_assign_costume_form_if_assignment_incomplete and return
    redirect_to_season_assignments_path_if_updated and return
    redirect_to assign_costume_path(@costume), danger: "Assignment failure: #{@costume.errors.full_messages.to_sentence}"
  end
def assign @previous_assignment_count = @costume . costume_assignments . count redirect_to_assign_costume_form_if_required_fields_empty and return @updated = @costume . update ( costume_params ) redirect_to_assign_costume_form_if_assignment_incomplete and return redirect_to_season_assignments_path_if_updated and return redirect_to assign_costume_path ( @costume ) , danger : "Assignment failure: #{@costume.errors.full_messages.to_sentence}" end
Studio
Receives data from assign costume form
POST /costumes/:id/assign
Studio Receives data from assign costume form POST / costumes / : id / assign
# gets no. of assignments before updating # check if the dance_season or song_name value is empty # try to persist to db # check that if updates, @costume.costume_assignments.count is now greater than count # redirect if updated correctly # redirect if costume assignments are invalid