diff --git a/app/controllers/hacks_controller.rb b/app/controllers/hacks_controller.rb index 213c38c7f..915e58882 100644 --- a/app/controllers/hacks_controller.rb +++ b/app/controllers/hacks_controller.rb @@ -27,7 +27,7 @@ class HacksController < ApplicationController # 筛选过滤与排序 params_filter_or_order # 我解决的编程题数 - user_codes = HackUserLastestCode.joins(:hack).mine(current_user).passed + user_codes = HackUserLastestCode.joins(:hack).mine_hack(current_user).passed @simple_count = user_codes.where(hacks: {difficult: 1}).count @medium_count = user_codes.where(hacks: {difficult: 2}).count @diff_count = user_codes.where(hacks: {difficult: 3}).count diff --git a/app/models/hack_user_lastest_code.rb b/app/models/hack_user_lastest_code.rb index 1d3e20f87..b4a707603 100644 --- a/app/models/hack_user_lastest_code.rb +++ b/app/models/hack_user_lastest_code.rb @@ -9,6 +9,7 @@ class HackUserLastestCode < ApplicationRecord has_many :hack_user_codes, dependent: :destroy has_one :hack_user_debug scope :mine, ->(author_id){ find_by(user_id: author_id) } + scope :mine_hack, ->(author_id){ where(user_id: author_id) } scope :passed, -> {where(status: 1)} end diff --git a/config/routes.rb b/config/routes.rb index abe31340d..81c419a7e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,7 +44,9 @@ Rails.application.routes.draw do get :start get :result end - resources :comments + resources :comments do + + end end resources :hack_user_lastest_codes, path: :myproblems, param: :identifier do