Search code examples
ruby-on-railssimple-form

how to disable simple_form validation in rails 7


could one kindly advise me how to disable simple form validation in rails 7. i am unable to remove the validation. it always states must exist no matter which way i use to remove the validation. Thank you for the advise in advance.

i have tried all the below:

required: false

html: { required: false }

html: { novalidate: true }

novalidate: true

simple_form_for(resource, html: { novalidate: true }) do

validates :category_addresstitle, presence: false

validates :category_addresstitle_id, presence: false

this is an association:

Address.rb
belongs_to :category_addresstitle

CategoryAddresstitle.rb
has_many :addresses 

address/form.html.erb
<%= f.association :category_addresstitle, collection: CategoryAddresstitle.all.order(:name), prompt: "Please Select", label: false %>

enter image description here


Solution

  • Make the association optional.

    belongs_to :category_addresstitle, optional: true