This project is archived and is in readonly mode.
undefined method `protect_against_forgery?' for #<ActionView::Base:0x10ad1a500>
Reported by David Chelimsky | May 26th, 2010 @ 07:08 AM
In a test for the new.html.erb template generated in the
scaffold generator, rendering the template results in
undefined method 'protect_against_forgery?'
.
This is happening because new.html.erb renders _form.html.erb,
which calls form_for
, which calls
FormTagHelper#extra_tags_for_form
, which calls
protect_from_forgery?
, which is not defined in the
scope in which it is being called.
I've got a patch that fixes this:
http://github.com/dchelimsky/rails/commit/53ba21a30fd359744cdee9acd...
Admittedly this is not perfect, but it does solve this problem without bleeding into other areas of the system.
Comments and changes to this ticket
-
David Chelimsky May 26th, 2010 @ 07:09 AM
- Tag set to action_view, patch, testing
- Assigned user set to José Valim
-
David Chelimsky May 26th, 2010 @ 07:10 AM
- Assigned user changed from José Valim to Carl Lerche
-
David Chelimsky May 26th, 2010 @ 07:10 AM
- Assigned user changed from Carl Lerche to Yehuda Katz (wycats)
-
David Chelimsky May 26th, 2010 @ 12:05 PM
I forgot there were two commits on that branch. In the previous commit I rearranged the tests in test_case_test. Here are the two commits (in order):
http://github.com/dchelimsky/rails/commit/44fda04e9a5e2d19a412104b5...
http://github.com/dchelimsky/rails/commit/53ba21a30fd359744cdee9acd...
If you want, I can squash them into one commit. If not, they should apply cleanly in that order.
Obrigado,
David -
Repository May 26th, 2010 @ 02:59 PM
- State changed from new to resolved
(from [e02db06ece7aeecec7c37f5b0e3de7d65c8684e6]) In AV::TC, move protect_against_forgery? from the test_case to the _helper module included in the view.
- ensures that protect_against_forgery? is present when a helper included in a partial that is rendered by the template under test calls it (which happens in FormTagHelper#extra_tags_for_form, for example).
[#4700 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/e02db06ece7aeecec7c37f5b0e3de7...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Tags
Referenced by
- 4700 undefined method `protect_against_forgery?' for #<ActionView::Base:0x10ad1a500> [#4700 state:resolved]