First! Make an app to test our awesome forms!
When trying to get a rails app up and running as quickly as possible, I have found generating a controller with specific views to be most useful. Example. Using new and result will automatically set a ‘get’ for new and result as well as a “new.html.erb” and “result.html.erb”.
Simple Form Tag
You can manipulate this in very simple ways. It can be used to create and post or simply do a search. The options are very diverse for this type of form and for sake of demonstration I have simply created a ‘get’ method and passed the value so you may see what is occurring. It is very easy to create a post method but for sake of brevity only ‘gets’ was used. Using the ‘gets’ allows me to easily just have the results page open when submit is clicked. Rails allows for builders to take in a specific path and method using <%= form_tag(“form/result”, method: “get”) do %>.
If you wanted to make a checkbox and grab its value its super simple. By default using rails to generate a check box sets values automagically to the value of 1. You my change its value by simply adding a parameter right after replacing the 1.
Much like a checkbox radio buttons give you a range of options but only allows you to check one option.