Monday
Nov192012
How to set Query Parameters in Rails form_for URLs
Mon 2012-11-19
In Rails 3.2.8, the following code fragment:
<%= form_for @resource, url: {p: '123'} do |f| %>
generates this HTML:
<form accept-charset="UTF-8" action="/resource/new?p=123" ... >
Multiple query parameters also work:
<%= form_for @resource, url: {p: '123', q: 'ABC'} do |f| %>
gives:
<form accept-charset="UTF-8" action="/resource/new?p=123&q=ABC" ... >
Reader Comments