Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcasimir/483518 to your computer and use it in GitHub Desktop.
Save jcasimir/483518 to your computer and use it in GitHub Desktop.
class PlacePage < Page
description "A page to display a single Place"
def find_by_url(url, live = true, clean = false)
url = clean_url(url) if clean
if Place.parse_url(url)
Page.find_by_title("single-place-template")
else
super
end
end
end
class Place < ActiveRecord::Base
...
def self.parse_url(url)
[$1, $2] if url =~ %r{\/places\/([^\/]*)\/?(.*)?}
end
def self.find_by_url(url)
place_param, location_param = parse_url(url)
Place.find_by_param(place_param) # Haven't done anything with the location_param yet
end
...
end
module PlacesTags
...
tag 'place' do |tag|
tag.locals.place = Place.find_by_url(@request.request_uri) if tag.locals.place.nil?
tag.expand
end
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment