Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Problem with String Interpolation breaks WWW::Mechanize

#3267

I will call this a Rails bug rather than a Mechanize bug because, I assume, code that runs in IRB should also run in the Rails console. The code is as follows:

require 'rubygems' 
require 'mechanize' 
require 'logger' 
require 'uri' 
require 'net/http' 
agent = WWW::Mechanize.new { |a| a.log = Logger.new("mech.log") } 
agent.user_agent_alias = 'Mac Safari' 
page = agent.get('http://www.fyi.legis.state.tx.us/Address.aspx') 
search_form = page.form_with(:name => "AddressForm") 
search_form.field_with(:name => "Address1").value = "501 W 26th St, 
Apt 110" 
search_form.field_with(:name => "City").value = "Austin" 
search_form.field_with(:name => "ZipCode").value = "78705" 
search_form.field_with(:name => "DistrictType").options[0].select 
res = agent.submit(search_form, search_form.buttons.first)

And here are the error messages:

ArgumentError: one hash required
from /home/jwoods/NetBeansProjects/activista/vendor/rails/actionmailer/lib/../../actionpack/lib/../../activesupport/lib/active_support/core_ext/string/interpolation.rb:85:in '%' 
from /usr/lib/ruby/1.8/webrick/httputils.rb:352:in 'escape' 
from /usr/lib/ruby/1.8/webrick/httputils.rb:352:in 'gsub' 
from /usr/lib/ruby/1.8/webrick/httputils.rb:352:in 'escape' 
from /usr/lib/ruby/1.8/webrick/httputils.rb:370:in 'escape_form' 
from /usr/lib/ruby/1.8/www/mechanize/util.rb:9:in 'build_query_string' 
from /usr/lib/ruby/1.8/www/mechanize/util.rb:6:in 'map' 
from /usr/lib/ruby/1.8/www/mechanize/util.rb:6:in 'build_query_string' 
from /usr/lib/ruby/1.8/www/mechanize/form.rb:199:in 'request_data' 
from /usr/lib/ruby/1.8/www/mechanize.rb:387:in 'post_form' 
from /usr/lib/ruby/1.8/www/mechanize.rb:331:in 'submit' 
from (irb):23

I am using edge rails and Mechanize from about four days ago. I had also tried with an earlier version of Rails.
Here's the revision stamp in my vendor/rails dir. I'm a noob, so apologies if I'm missing information. I'll be happy to find whatever you all need.
REVISION_3600c3840e8d0c612c974e6af5ce010535492fbe

Reported by John Woods · September 26th, 2009 @ 09:39 PM

State: duplicate
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from active_support core_ext, string interpolation, interpolation, string, www::mechanize to active_support core_ext, string interpolation, bugmash, interpolation, string, www::mechanize

    September 27th, 2009 @ 11:29 AM

  2. Rizwan Reza
    Rizwan Reza
    • Tag changed from active_support core_ext, string interpolation, bugmash, interpolation, string, www::mechanize to active_support core_ext, string interpolation, interpolation, string, www::mechanize

    February 12th, 2010 @ 12:46 PM

  3. Henrik Nyh
  4. Ryan Bigg
    Ryan Bigg
    • State changed from new to duplicate
    • Importance changed from to

    According to #4052 ActiveSupport breaks literal "%%" in non-hash String interpolation, this has been fixed. Please mention on that ticket if this is not the case.

    October 11th, 2010 @ 01:03 AM