Corrected an error with Form Roles vs Rolify Roles. Forms view for create and edit now show the correct roles that should be assigned.
This commit is contained in:
parent
bb9c354146
commit
6d03d80a31
|
@ -25,7 +25,7 @@ class FormsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if @form.update(form_params)
|
if @form.update(form_params[:id])
|
||||||
redirect_to @form, notice: 'Form was successfully updated.'
|
redirect_to @form, notice: 'Form was successfully updated.'
|
||||||
else
|
else
|
||||||
render :edit
|
render :edit
|
||||||
|
@ -50,7 +50,7 @@ class FormsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def form_params
|
def form_params
|
||||||
params.require(:form).permit(:name, :required, :program, role_ids: [])
|
params.require(:form).permit(:name, :required, :program, form_role_ids: [])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,12 @@ class Form < ApplicationRecord
|
||||||
after_save :update_onboarding_items
|
after_save :update_onboarding_items
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def form_role_ids=(ids)
|
||||||
|
self.form_roles = ids.reject(&:blank?).map { |id| Role.find(id) }
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def update_onboarding_items
|
def update_onboarding_items
|
||||||
roles.each do |role|
|
roles.each do |role|
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<%= f.label :role_ids, 'Roles', class: 'form-label' %>
|
<%= f.label :form_role_ids, 'Roles', class: 'form-label' %>
|
||||||
<%= f.collection_select :role_ids, Role.all, :id, :name, {}, { multiple: true, class: "form-control" } %>
|
<%= f.collection_select :form_role_ids, FormRole.all, :id, :name, {}, { multiple: true, class: "form-control" } %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
|
|
Loading…
Reference in New Issue