0

How could I enforce user to choose a service_type,

because when the page loaded, the select option shows "choose one?" by default

-service_type=[a,b,c]
= f.input :service_type, label: "service", collection: @service_type, prompt: "choose one?"

Thanks~

1 Answer 1

0

by setting the model attribute to the value you want to enforce before rendering the input:

- f.object.service_type = your_default_service_type
= f.input :service_type, label: "service"....

I'd recommend you to do it on the model or the controller other than in the view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.