Handle nullable foreign key in multiselect#2446
Conversation
dd4ad2f to
b86b269
Compare
b86b269 to
c2f12af
Compare
…multiselect Handle nullable foreign key in multiselect
|
Thanks for your work! 🍺 |
|
@jibidus @mshibuya it seems that this PR breaks I've got relation: promotion has many user_promotions when I'm opening view to add new promotion, I can add users there, and what happens during this code execution: def foreign_key_nullable?
return if foreign_key.nil? || type != :has_many
klass.columns_hash[association.foreign_key].null
endis that Any idea how to fix it? |
|
@arnvald Let me have a look. |
|
@arnvald I didn't manage to reproduce the issue 😩 . |
|
@jibidus I created a simple application here: https://github.com/arnvald/rails_admin_polymorphic_bug To reproduce:
I'll try to write a spec that'll cover this case, either today or tomorrow. |
|
@jibidus thanks for fixing the bug! |
|
How can i configure this manually? i want some has_many fields without those buttons to remove the association. But adding Does nothing. |
|
This Pull Request was designed to prevent displaying the |
|
I made my own custom field for my use case, i don't want the foreign key nullable i wanted that field to not have that remove button on that particular model, so this is what i did: |
has_manywith not nullable foreign may raise exception when user try to remove elements from corresponding association.The aim of this request is to prevent such behavior with disabling
removeactions from form.