The URL Police

Matt Jankowski

''

I think we can all agree that seeing a form (like search, for example) which is going to send a message in a bottle, or even as part of a GET request should not include that dirtiest of url params — commit=Submit or commit=Go.

When you send your SOS to the world, you want it be to be nice and clean, don’t you? I mean, if a year has passed since you wrote your note…well, it’s time restart your mongrels.

Doing a GET to /messages/search?query=SOS&to=TheWorld is ok … but /messages/search?query=SOS&to=TheWorld&commit=Submit should not stand.

So here is a short GR reader survey. When dealing with this default markup…

<input name="commit" type="submit" value="Submit" />

…which solution to removing the name=commit do you take?

Are you simple?

    <%= submit_tag 'Submit', :name => '' %>

Are you precise?

<%= submit_tag 'Submit', :name => nil %>

Have you gone overboard?

<%= submit_tag 'Submit', :name => String.new %>

Have you lost your mind? (note that this doesn’t actually work but I think we’d all love it if it did)

<%= submit_tag 'Submit', :name => NilClass.new %>

Or, are you enterprise?

<%= submit_tag 'Submit', :name => submit_input_name %>

helper_method :submit_input_name
def submit_input_name
  @_submit_input_name ||= nil
end

Well, what are you?