Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Commit

Permalink
Admin: Add user tags to to user form
Browse files Browse the repository at this point in the history
  • Loading branch information
buren committed Jan 8, 2017
1 parent 8220822 commit 00bc2a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/admin/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@
end

f.inputs I18n.t('admin.user.form.competences') do
f.has_many :user_tags, allow_destroy: true, new_record: true do |ff|
ff.input :tag, as: :select, collection: Tag.all
end

f.has_many :user_skills, allow_destroy: false, new_record: true do |ff|
ff.semantic_errors(*ff.object.errors.keys)

Expand Down Expand Up @@ -520,8 +524,9 @@
:password, :language_id, :company_id, :managed, :frilans_finans_payment_details,
:verified, :interview_comment, :banned,
:language_ids, :skill_ids, ignored_notifications: [],
user_skills_attributes: [:skill_id, :proficiency, :proficiency_by_admin],
user_languages_attributes: [:language_id, :proficiency, :proficiency_by_admin]
user_skills_attributes: [:skill_id, :proficiency, :proficiency_by_admin], # rubocop:disable Metrics/LineLength
user_languages_attributes: [:language_id, :proficiency, :proficiency_by_admin], # rubocop:disable Metrics/LineLength
user_tags_attributes: [:id, :tag_id, :_destroy]
]
UserPolicy::SELF_ATTRIBUTES + extras
end
Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class User < ApplicationRecord

# NOTE: This is necessary for nested activeadmin has_many form
accepts_nested_attributes_for :user_skills, :user_languages
accepts_nested_attributes_for :user_tags, allow_destroy: true

# Don't change the order or remove any items in the array,
# only additions are allowed
Expand Down

0 comments on commit 00bc2a8

Please sign in to comment.