Hey guys. I’ve been trying to figure out where in my app this
functionality should go, but I’m really not sure. Any suggestions?
- A map can be created for a Neighbourhood or Property.
- A map has zero or more markers.
- A marker contains HTML formatted from a template, using a
#1 means that the map functionality should be separate from
Neighbourhoods and Properties, otherwise it won’t be DRY. IMO, this
suggests that I should create a map model, or put the mapping
functionality in a module in lib/ .
#3 is related to views. The marker HTML template could go in a:
-view helper. However, only views have access to view helpers, so the
helper would only be accessible from the view. This would require
putting business logic into the view. Ew.
-partial. The Neighbourhood and Property controllers could then use
#render_to_string to generate each marker’s contents. I don’t believe
it’s possible [without an ugly kludge, at least] to get a model to
call #render_to_string .
My current line of thinking is:
-Create a ‘map’ model.
-Put the map marker HTML template in a partial.
-The Neighbourhood and Property controllers create a map instance.
-The Neighbourhood and Property controllers add map markers.
-Addng map markers calls #render_to_string to generate a marker’s
However, I feel like the Neighbourhood and Property models should be
creating the map instance and adding markers.
Any suggestions? I’m all ears!