Trying to figure out if this is a helper or a controller or a partial?

I have an app that I am trying to generate out some GoogleMaps. The
GoogleMaps aren’t the problem, I am tripping over the proper way to
handle what I want to do.

I have a DB for map markers.

Path 1:
When the user makes a call to the controller => “mymap”, action =>
“show”, I grab the id parameter.
From here, if 15 minutes have passed since it was last checked, I make
a call to a function check_map_update that makes an RSS call to an
outside repository and puts the changes in the map marker DB. Show
then goes on to read the map markers and generate a map shown by the
view.

Path 2:
In my view, I want it to pull up some thumbnails of other maps, so I
make a helper called “show_thumbnail”, which I put a <% render %> call
in that returns the image to display.

MapController
def show
def check_map_update

MapHelper
def map_thumbnail

View:
Application.html.erb
map/show.html.erb

My Problem:
I want to be able to call check_map_update from the function in the
helper. Or, is the helper the best place for this? render partial
seems to be little help since it doesn’t run controller code either.
What I really would have liked to have is a controller that calls a
couple other actions like show/1, show/53, and includes those as part
of the page, but I can’t quite figure out the proper place for that
and I can’t find a tutorial or decent document that says how to do it.

My current thought is that check_map_update should be in the map
model. But how would I go about showing multiple maps from the
controller?

On 5 March 2010 21:56, John G. [email protected] wrote:

a call to a function check_map_update that makes an RSS call to an
def show
I want to be able to call check_map_update from the function in the
helper. Or, is the helper the best place for this? render partial
seems to be little help since it doesn’t run controller code either.
What I really would have liked to have is a controller that calls a
couple other actions like show/1, show/53, and includes those as part
of the page, but I can’t quite figure out the proper place for that
and I can’t find a tutorial or decent document that says how to do it.

My current thought is that check_map_update should be in the map
model. But how would I go about showing multiple maps from the
controller?

I am not sure whether this will help or not but is it possible that
the underlying cause of the problem is that you are generating the map
in the controller? A map is after all a view on some data so arguably
should be generated in the view. If in the controller you just setup
whatever variables are required to define the map parameters, markers
and so on, and move the map generation to the view (with actual code
in the model or helpers of course) things might work out easier. In
the particular case you mention the controller would just need to
define that maps 1 and 53 should be shown and the view would show
them.

Colin

Quoting John G. [email protected]:

a call to a function check_map_update that makes an RSS call to an
def show
I want to be able to call check_map_update from the function in the

I would do something different. Unless you can guarantee the the RSS
server
is always up and there is never any congestion between the application
server
and the RSS server (e.g., they are on the same machine or same LAN), I
would
move the map update to run every 15 minutes. If it is run at the time
of the
show request, it may take 30 seconds or more to timeout if the server is
down.
If also may take a while to update the map model from the RSS feed. Is
is
best for responsiveness if this is down outside the user request.

I have been working on an adaptive RSS reader (AmethystRSS.net) for a
while
and have found that updates can take longer than the user is willing to
wait
and timeouts (i.e., no response in 30 seconds or whatever Ruby/Rails
sets
timeout), 404 errors, 500 errors, etc. are common. Out of the 200+
feeds I
read, there are always some that are not fully functional at any given
read.
An hour later (15 minutes in your case), they are fine.

HTH,
Jeffrey

Quoting Jeffrey L. Taylor [email protected]:

From here, if 15 minutes have passed since it was last checked, I make
MapController
My Problem:
controller?
I have been working on an adaptive RSS reader (AmethystRSS.net) for a while
and have found that updates can take longer than the user is willing to wait
and timeouts (i.e., no response in 30 seconds or whatever Ruby/Rails sets
timeout), 404 errors, 500 errors, etc. are common. Out of the 200+ feeds I
read, there are always some that are not fully functional at any given read.
An hour later (15 minutes in your case), they are fine.

I am still wavering between making the RSS feed itself a
non-ActiveRecord
model versus adding the code to the related model, Map in your case.
Maybe
with the switch to ActiveModel in Rails3 it will become clearer.

Jeffrey

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs