Ruby on Rails controller-view refactoring
- by Dimitar Vouldjeff
Hello,
In my app I am using the ym4r-gm plugin, which allows you to play with the Google Maps API... I put the map "setup" in the controller:
@map = GMap.new("div_map")
@map.control_init(:large_map => true, :map_type => true)
@map.center_zoom_init([47.0, 26.0], 7)
...
And only render @map in the view.
So my first question is whether I am using the right approach of "diving" this code?
And the second question is: I have to models, which are rendering the same map (only the resources are different). Where should I put my refactored method that renders the map? In the application controller, maybe?
Thanks in advance,
I hope you will understand me!