Chris Mendla
Chris Mendla

Reputation: 1017

How do I get the values of the params from a form

I need to work with the inputs from a form before storing the records. I'm stuck at simply reading the params.

In my create controller, I have

def create
   @document_history = DocumentHistory.new(document_history_params)
   $temp1 = params[:by]
   $temp2 = params[:sent_to]

In my show, I have

<hr>
<%= $temp1 %>
<hr>
<%= $temp2 %>

On the show, $temp1 and $temp2 are blank. How can I read the params and store the value to a variable?

Upvotes: 0

Views: 193

Answers (1)

sureshprasanna70
sureshprasanna70

Reputation: 1045

I am assuming that your fields are named in the standard rails way.That is,If your input fields are named like this document_history[name] then the correct way to access them would be params[:document_history][:name]. To verify if they have been copied to your variable you can print to log.

Upvotes: 1

Related Questions