Answer the question
In order to leave comments, you need to log in
Rails How to display POST variables in a form?
Hello, I can’t display variables from POST in Rails
, I have a display with a form
<h1>Formularz nowego uzytkownika</h1>
<%= form_tag({ :action => 'show' }, { :method => :post }) do %>
<%= label_tag("Name:") %>
<%= text_field("person", "name") %><br/><br/>
<%= submit_tag("Ok") %>
<% end %>
Answer the question
In order to leave comments, you need to log in
Found the answer:
in the display there should be such a code
<%= form_tag("/user/show", method: "post") do %>
<%= label_tag("name:") %>
<%= text_field_tag("name") %><br/><br/>
<%= label_tag("surname:") %>
<%= text_field_tag("surname") %><br/><br/>
<%= label_tag("Age:") %>
<%= text_field_tag("age") %><br/><br/>
<%= submit_tag("Ok") %>
<% end %>
class UserController < ApplicationController
def index
#@user = User.new
end
def show
@name = params[:name]
@surname = params[:surname]
@age = params[:age]
end
end
<h1>Show</h1>
<div clas="form">
name:<%= @name %><br/>
surname:<%= @surname %><br/>
age:<%= @age %><br/>
</div>
<%= link_to('Click here', controller: 'pages',
action: 'index') %>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question