user2006824
user2006824

Reputation: 1

Take input in the view and pass it to the contoller

The following code in not rendering even the buttons:

<% form_tag :controller=> :create_new, :action=>:input do %>
<%=text_field_tag :my_input%>
<%=submit_tag "Send input"%>
<%end%>

the controller create_new has the following method:

def input
@my_input=params[:my_input]
end

the routes.rb has::

resources :create_new do
   post :input, :on=>:collection

Upvotes: 0

Views: 82

Answers (3)

Sachin R
Sachin R

Reputation: 11876

<%= form_tag input_create_new_path, :html_options => {:method => :post} do |f| %>
  <%= f.text_field :my_input%>
  <%= f.submit "Send input"%>
<%end%>

Upvotes: 0

vijikumar
vijikumar

Reputation: 1815

For rails 3 we have to use '=' symbol for form_tag and form_for. so change your code as follows..

 <%=form_tag :controller=> :create_new, :action=>:input do %>
 <%=text_field_tag :my_input%>
 <%=submit_tag "Send input"%>
 <%end%>

Upvotes: 0

Alexey
Alexey

Reputation: 546

Use <%= form_tag instead of <% form_tag.

Upvotes: 1

Related Questions