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
|
||||
|
||||
def update
|
||||
if @form.update(form_params)
|
||||
if @form.update(form_params[:id])
|
||||
redirect_to @form, notice: 'Form was successfully updated.'
|
||||
else
|
||||
render :edit
|
||||
|
@ -50,7 +50,7 @@ class FormsController < ApplicationController
|
|||
end
|
||||
|
||||
def form_params
|
||||
params.require(:form).permit(:name, :required, :program, role_ids: [])
|
||||
params.require(:form).permit(:name, :required, :program, form_role_ids: [])
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -11,6 +11,12 @@ class Form < ApplicationRecord
|
|||
after_save :update_onboarding_items
|
||||
|
||||
private
|
||||
|
||||
def form_role_ids=(ids)
|
||||
self.form_roles = ids.reject(&:blank?).map { |id| Role.find(id) }
|
||||
end
|
||||
|
||||
|
||||
|
||||
def update_onboarding_items
|
||||
roles.each do |role|
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<%= f.label :role_ids, 'Roles', class: 'form-label' %>
|
||||
<%= f.collection_select :role_ids, Role.all, :id, :name, {}, { multiple: true, class: "form-control" } %>
|
||||
<%= f.label :form_role_ids, 'Roles', class: 'form-label' %>
|
||||
<%= f.collection_select :form_role_ids, FormRole.all, :id, :name, {}, { multiple: true, class: "form-control" } %>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
|
|
Loading…
Reference in New Issue