This project is archived and is in readonly mode.
Templates that use with_options...
Reported by VirtualFunction | April 17th, 2010 @ 04:04 PM | in 3.0.2
If I do something like:
= form_for some_object do |form|
- form.with_options :class => 'text' do |input|
= input.text_field :description
Under production mode in Rails 3.0 (trunk/beta3, with Ruby 1.9.2 x64 trunk) will output the text_field twice. This doesn't happen in development mode.
Admittedly this is in HAML, but pretty certain this will happen in ERB too, as I guess this is to do with fixing helpers like form_for and form_tag that output text within a do block as they previously needed to use '-' instead of '=' while using concat behind the scenes.
The use of the '-' notation in templates shouldn't output anything is my take (exception being form_for, form_tag etc purely for some level of backward compatibility with Ruby 2.x)
Oddly enough, this happens with the with_options method, but I don't seem to notice it with loops such as for statements or Array#each calls
Comments and changes to this ticket
-
David Workman April 17th, 2010 @ 04:37 PM
There is an error there... you are using '=' for the form_for line.
-
iain April 17th, 2010 @ 10:13 PM
@David: That's not an error. In Rails 3 you should do this. That works even in HAML.
-
José Valim August 27th, 2010 @ 07:45 PM
- Milestone cleared.
- State changed from new to open
- Assigned user set to Yehuda Katz (wycats)
- Importance changed from to High
-
Carlos Antonio da Silva August 27th, 2010 @ 07:51 PM
This error just happened to me while in development, and I created a test case showing the issue.
The same patch attached is also in this pastie: http://pastie.org/private/t66q1nzqhrwg0afl1bkmw, which contains the test suite output showing the double render issue. -
Marjan Krekoten' August 28th, 2010 @ 08:24 PM
I attached patch that fixes this issue. It also contains test patch from Carlos Antonio da Silva.
-
VirtualFunction August 28th, 2010 @ 10:05 PM
Many thanks everyone with the recent activity here. Just curious, will these patches make HAML work as expected too? If not I assume I will need to also raise this with the HAML dev(s)
-
Trotter Cashion September 14th, 2010 @ 12:40 AM
The patch from Marjan works for us on the 3-0-stable branch. Had an conflict applying it to master, however. Let us know if you'd like us to patch.
-
José Valim September 23rd, 2010 @ 10:48 PM
- State changed from open to resolved
This is already fixed in master.
-
Marjan Krekoten' September 23rd, 2010 @ 11:25 PM
Cool. Can you please point me to commit that fixed this issue? I can't find it but it is interesting for me for self education.
Thx!
-
Justin Halsall January 20th, 2011 @ 02:54 PM
I'm looking at master and it seems as if the patch hasn't been added.
-
Samuel Kadolph January 20th, 2011 @ 02:56 PM
This patch isn't applied in master or 3-0-stable.
For anyone that needs it now, put this in
config/initializers
. -
José Valim January 20th, 2011 @ 03:00 PM
The patch wasn't applied on master but it was fixed in a different way. I have even pushed the test case added by Carlos.
We won't apply the patch to 3-0-stable because whitelistening "with_options" is too brittle as solution to be applied in Rails as whole.
-
mdrozdziel February 28th, 2011 @ 03:30 PM
I am still getting this error with 3.0.5. What is the best workaround?
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>