0

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 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.