On this page...
http://guides.rubyonrails.org/form_helpers.html
... in section 1.3 it says:
When the form is submitted, the name will be passed along with the form data, and will make its way to the params hash in the controller with the value entered by the user for that field.
The form I'm trying to add is on a page (with a view) called 'whattypeofleaderareyou.html.rb'. How do I tell which controller is being used? Is that dependent on how the user got to the page? (ie, the last URL request?).
I know this is probably not at all helpful, but the button that takes you to this page has the html:
<a class="btn btn-default" href="/whattypeofleader">next</a>
But that obviously doesn't tell me much about which controller is used for the page with the form.
I realise there must be something fundamental I'm not getting about this, but could someone please take the time to point out what it is, and ideally explain it?
I should add that I have repeatedly checked 'rake routes' but I think there's some meaning about the list of routes mapped to paths that I don't appreciate. I suspect the list of routes to paths is significant, but I don't understand its meaning. If someone could explain that, that would also be great.
You can run rake routes
to get a listing of the available routes and the controller they match.
If the application is running and you know the URL you want to find the matching controller, when you run rails s
you can see in it's output which controller's method is executing:
Started GET "/answers" for 127.0.0.1 at 2014-12-09 11:45:10 -0300
Processing by AnswersController#index as HTML
Answer Load (0.3ms) SELECT "answers".* FROM "answers"
Rendered answers/index.html.erb within layouts/application (3.2ms)
Completed 200 OK in 88ms (Views: 68.4ms | ActiveRecord: 2.4ms)
You see the request was GET /answers
, and was attended by AnswersController
's index
method here.