My index action currently looks like this
def index
@pictures = Picture.search(params[:page])
respond_to do |format|
format.html
format.json { render :text => @pictures.to_json }
end
end
format.json is used to display the location of pictures on a map. The
javascript code is simple and looks like this:
function listMarkers() {
var request = GXmlHttp.create();
request.open(‘GET’, ‘pictures.json’, true);
request.onreadystatechange = function() …
The problem is that the json output always assumes it’s on the first
page since it has no idea what params[:page] is. So while the view is
on page 2 the map still shows markers for page 1. Is there a way to
have format.html and format.json output the same @pictures so that the
markers on the map correspond to what’s in the view?