1, Strip &submit=xxx in url; 2, Keep the search keyword in input field

Tuesday, March 23, 2010

strip &submit=Search in url

<%= submit_tag "Search", :name => nil %>

# keep the search keyword in input field
<%= text_field_tag :search, params[:search] %>

to_safe_uri

class String
  def to_safe_uri
    self.strip.downcase.gsub('&', 'and').gsub(' ', '-').gsub(/[^\w-]/,'')
  end
end

This entry was tagged Ruby

comments powered by Disqus

© 2009-2013 lxneng.com. All rights reserved. Powered by Pyramid

go to Top