views:

24

answers:

1

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!

+1  A: 

Depending on the size of you project. You could add it to the application controller, in case you want other controllers to take advantage of it. Or you could create a new module and put your code in there, this way you will need to include it into models/controllers that need it only.

I'd prefer the latter, since it is more structured that way and application controller is not cluttered. But this is really a personal choice.

Zepplock