I\'m making good progress with my first Rails app (using Rails 3). The MVC interaction is all going fine, but I\'m having difficulty with a form that doesn\'t relate directl
If your field has a default, you will want to set it from the "show" action for the form:
# GET
def show_form
params[:key] = 'default'
end
# POST
def validate_form_and_act
# Don't set it here to reuse what the user passed.
end
or directly on the template (less good because uses an ||
every time and adds more controller data to view):
<%= text_field_tag 'name', params[:key] || 'default' %>
The second arg to text_field_tag is the value to fill in the field with. Try something like this:
<%= text_field_tag "separator", params[:separator], :maxlength => 1 %>