mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-14 11:24:22 +01:00
* Removed tag_object() from application_helper as it was not being used. * Introduced link_to_context() and link_to_project() helper methods. * Fixed a javascript syntax error on the context page. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@373 a4c988fc-2ded-0310-b66e-134b36920a42
20 lines
No EOL
456 B
Ruby
20 lines
No EOL
456 B
Ruby
module UrlFriendlyName
|
|
|
|
def self.included(base)
|
|
base.extend ClassMethods
|
|
end
|
|
|
|
def url_friendly_name
|
|
name.gsub(/_/,'__').gsub(/ /,'_').gsub(/\./,'__dot__')
|
|
end
|
|
|
|
module ClassMethods
|
|
|
|
def find_by_url_friendly_name(url_friendly_name)
|
|
name = url_friendly_name.gsub(/__dot__/,'.').gsub(/([^_])_(?!_)/,'\1 ').gsub(/__/,'_') #second regex replaces all single underscores with spaces
|
|
self.find_by_name(name)
|
|
end
|
|
|
|
end
|
|
|
|
end |