Created
March 7, 2012 13:05
-
-
Save edzhelyov/1992995 to your computer and use it in GitHub Desktop.
Search helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Search | |
class NotUrlHelperPresent < Exception; end | |
attr_writer :url_helper | |
def url(params) | |
raise NotUrlHelperPresent unless @url_helper | |
@url_helper.call(params) | |
end | |
end | |
# Usage example: | |
search = Search.new :brokers | |
seearch.url_helper = method(:brokers_path) | |
# and in the template: | |
<%= search.url(:search => search.to_hash) %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment