rails

POST to the Same Page and Verify Results in Rails

Shou Arisaka
1 min read
Oct 22, 2025
// routes.rb
get 'dev/form'
post 'dev/form'

// form.html.erb
<%= form_tag(dev_form_path, method: "post") do %>
  <%= label_tag(:q, "Search for:") %>
  <%= text_field_tag(:q) %>
  <%= submit_tag("Search") %>
<% end %>

<%= params[:q] %>

form.html.erb is POSTing to form.html.erb itself.

With this, the single page application is complete.

Since we only write this much and only use two files, it's easy to manage, right.

Share this article

Shou Arisaka Oct 22, 2025

๐Ÿ”— Copy Links