Deepender Singla
Deepender Singla

Reputation: 997

Taking a input from user in Ruby on rails

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?

Upvotes: 0

Views: 389

Answers (2)

smudge
smudge

Reputation: 831

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

Upvotes: 3

EmFi
EmFi

Reputation: 23450

params[:q]

Should get you what you're looking for.

Upvotes: 1

Related Questions