« Lauxaniid Fly | Main | Fungus »

How to set Query Parameters in Rails form_for URLs

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| %>


  <form accept-charset="UTF-8" action="/resource/new?p=123&q=ABC" ... >

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
All HTML will be escaped. Hyperlinks will be created for URLs automatically.