0

I wanted to assign a value from a form, to a variable, so I can work with that value before I save it. Also how I add a t.text_field that doesn't require a variable, wont be saved, wont do anything, i just wanted to be there.

1 Answer 1

1

HTML does not have variables. I'm assuming you want to assign the value of a form input to a variable in your controller? That is what the params hash is for. In your controller you could assign the value of a input called field like this

myField = params[:thing][:field] 

You can always add an input to a form and ignore it in your controller. Open the form with something like this

<%= form_for @thing do |f| %>

Then you can add a random input that's not part of your thing model like

<%= text_field_tag :randomInput %>

You can read up on form helpers here http://guides.rubyonrails.org/form_helpers.html

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

1 Comment

Exactly this, Thanks alot!

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.