0

I am using ROR , For my app user input is needed in view.For this i am using this:

<%= form_tag("/new", method: "get") do %>
  <%= label_tag(:q, "Search for:") %>
  <%= text_field_tag(:q) %>
  <%= submit_tag("Search") %>
<% end %>

My question is,how can i access the text user enter into text field into my controller new action?

2 Answers 2

3

The element text_field_tag(:q) should submit a parameter "q", which can then be read on the server by calling params[:q].

Sign up to request clarification or add additional context in comments.

Comments

1
params[:q]

Should get you what you're looking for.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.