I'm using it on my current project and run into a small problem. It doesn't work nicely with array data, like for example multiselect fields emulation, so when you do something like that
agent = Mechanize.new
agent.post('http://boo.boo/boo', {
'param[]' => ['one', 'two', 'three']
});
In the reality it sends the 'one' value only. I've sent a little patch to the devs, but it seems like it will take time before they do something about it. So here is how you fix it in your rails app.
In any initializers in your `config/initializers/` directory add the following lines.
class Mechanize::Form::Field
def query_value
if @value.is_a?(Array)
@value.collect{ |v| [@name, v || '']}
else
[[@name, @value || '']]
end
end
end
After that it will be just fine.
No comments:
Post a Comment