fix interest

dev_course
p31729568 6 years ago
parent a189f57844
commit 3f3f7ed854

@ -1,21 +1,21 @@
class Users::InterestsController < Users::BaseController
skip_before_action :check_observed_user_exists!
before_action :require_login
before_action :private_user_resources!
def create
identity = params[:identity].to_s.strip
extension = observed_user.user_extension || observed_user.build_user_extension
extension = current_user.user_extension || current_user.build_user_extension
return render_error('请选择职业') unless %w(teacher student professional).include?(identity)
ActiveRecord::Base.transaction do
extension.update_column(:identity, identity)
# 兴趣
observed_user.user_interests.delete_all
current_user.user_interests.delete_all
UserInterest.bulk_insert(:user_id, :repertoire_id) do |worker|
(Repertoire.pluck(:id) & Array.wrap(params[:interest_ids]).map(&:to_i)).each do |repertoire_id|
worker.add(user_id: observed_user.id, repertoire_id: repertoire_id)
worker.add(user_id: current_user.id, repertoire_id: repertoire_id)
end
end
end

@ -47,7 +47,6 @@ Rails.application.routes.draw do
resource :experience_records, only: [:show]
resource :grade_records, only: [:show]
resource :watch, only: [:create, :destroy]
resource :interest, only: [:create]
end
@ -78,6 +77,7 @@ Rails.application.routes.draw do
resource :auth_attachment, only: [:update]
resource :authentication_apply, only: [:create]
resource :professional_auth_apply, only: [:create]
resource :interest, only: [:create]
end
end
end

Loading…
Cancel
Save