#389 new
Jarl Friis

Webrat does not pass empty form fields correctly to Rails

Reported by Jarl Friis | August 9th, 2010 @ 09:42 AM

The problem is that it always generate query_strings even for values that are not set. Rails usually set blank parameters to nil when.

Here is a patch:

--- /var/lib/gems/1.8/gems/webrat-0.7.1/lib/webrat/core/elements/field.rb.org   2010-08-09 15:27:36.529197447 +0200
+++ /var/lib/gems/1.8/gems/webrat-0.7.1/lib/webrat/core/elements/field.rb       2010-08-09 15:38:17.589854810 +0200
@@ -129,7 +129,7 @@
       if @value.is_a?(Array)
         @value.collect {|value| "#{name}=#{ escape_value ? escape(value) : value }" }.join("&")
       else
-        "#{name}=#{ escape_value ? escape(value) : value }"
+        "#{name}=#{ escape_value ? escape(value) : value }" if value
       end
     end

Jarl

Comments and changes to this ticket

  • Jarl Friis

    Jarl Friis August 9th, 2010 @ 10:26 AM

    I am sorry.

    I believe this is an invalid ticket. I am not right in the claim "Rails usually set blank parameters to nil when [fields are empty]"

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

People watching this ticket

Pages