Sorry guys - I don’t want to be a help vampire, but I’ve been through a
ton of tutorials, and they’re all written by guys who obviously have a
solid backing in programming already because they seem to plow through
without really explaining how things work in a way I (i.e. idiots) can
understand.
Anyway, thanks to everybody who helped me yesterday. You helped me send
a value to a view. Now I’m trying to send a value from a text field back
to the controller to check and see if it’s the correct answer. But I
don’t quite understand how Rails wants me to do this.
Here, for example:
<%= start_form_tag :action => ‘answer’ %>
<%= text_field ‘questions’, ‘answer’ %>
<%= submit_tag ‘check answer’ %>
<%= end_form_tag %>
I went to the Rails API and found the explanation of text_field: the
first value is the object, and the second value is the method. But I
already set up the method that I want to go to in the start_form_tag
part. So for some reason I have to call it twice? But my biggest issue
is, where do I put the value that the user will enter into the form
field? And how do I retrieve that value once I’m in the ‘answer’ method
in the controller? I’m used to PHP and HTML forms, where you specify a
name=“something” and then you can get the variable called “something”
from the _POST array. But how does Rails do this? Obviously there’s no
_POST array, but what is the Rails equivalent?
Again, thanks and apologies in advance for being the newbie with all the
questions.