For instructional purposes, I'd like to generate scaffolds which showcase radio buttons. You can generate a scaffolding with checkboxes with:
rails generate scaffold Person name:string honest:boolean
boolean
data types create checkboxes for the _form.html.erb file used when creating or editing people above. Is there anything that creates radio buttons?
No, not using the default scaffold generator. Each attribute type (integer, string, boolean etc) defaults to one field type. See rails/generators/generated_attributes.rb for how it is implemented.
If you still want to automatically create radio-buttons for the boolean values, you may have to override the default scaffold generator. Here's some documentation on how to do that , though I recommend that you change your check_box
fields to radio_button
fields manually.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.