Reputation: 19
I'm fairly new to rails and didin't find a soloution after a lot of research...
I want to build a simple data abstaraction test app. I have a text field and a submit button and I want to do something with the input (like ie. .upcase
) and then print it out. On submit, I get a routing error, though.
What am I doing wrong?
application.html.erb
<body>
<%= form_tag("parse_input", method: "post") do %>
<%= text_field(:ans, :field) %>
<%= submit_tag("submit" %>
<% end %>
FormControllerController.rb
class FormControllerController < ApplicationController
def parse_input
params[:ans].each do |value|
puts value
end
end
end
routes.rb
Rails.application.routes.draw do
...
root :to => 'application#home'
get "application" => "form_controller_controller"
end
I don't want to use a DB btw.
Upvotes: 0
Views: 3161
Reputation: 4427
Try below code:
Rails.application.routes.draw do
...
root :to => 'application#home'
post "parse_input" => "form_controller_controller#parse_input"
end
<body>
<%= form_tag("/parse_input") do %>
<%= text_field(:ans, :field) %>
<%= submit_tag("submit") %>
<% end %>
Upvotes: 1