Forum: Ruby on Rails Remote pagination using pagination_links, link_to_remote and

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
John L. (Guest)
on 2007-04-27 01:51
(Received via mailing list)
I have two controllers, 'ads' and 'markets'.  In the ads controller I
have a
page that shows some partials from the markets view.  I could create
partials within the 'ads' view and methods in the 'ads' controller but
seems like i would be out of bounds.   Since the markets partials were
identical to some pieces i had already created and I might want to use
partial elsewhere in the future, I thought it would be best to keep
with markets.

So now I show a view within ads and I have a partial rendered using
pagination.  I want to be able to move from page to page within the list
(and filter it) and ultimately choose a record/row from the list and use
within the current view.   However, somewhere along the string of method
calls to build the pagination links some method filters out my
and :action assignments and replaces them with the current values.  So
should be /markets/min_filter_lookup/?page=2 ends up being
/ads/assign_markets/?page=2 (the current view).  The result of course is
entire new page/layout being rendered and returned, where I only want

Below is the method I use to generate the remote pagination links.  It
started as a method in my application helper that I only used within one
view/controller, but I recently added some additional params/cases to
use it
to handle my current situation.  If you look at the code below you can
see I
have one line commented out.  I replaced that url_for call with the
url, somewhat hard-coded, and it works.  Maybe I don't understand
Maybe it's a combination of a few methods?  (Either way I have a feeling
that the answer is extremely simple)

  def pagination_links_remote(paginator, controller = nil, prefix = '')
    page_options = {:window_size => 4}
    target = prefix.nil? ? 'filter_by_list' : "#{prefix}_filter_by_list"
    action = prefix.nil? ? 'filter_lookup' : "#{prefix}_filter_lookup"

    plinks = pagination_links_each(paginator, page_options) do |n|

      if controller.nil?
        options = {
          :url => {:action => action, :params => @params.merge({:page =>
          :update => target,
          :before => "'filter_by_activity_indicator')",
          :success => "Element.hide('filter_by_activity_indicator')"
        html_options = {:href => url_for(:action => action, :params => @
params.merge({:page => n}))}
        options = {
#          :url => url_for(:controller => controller, :action => action,
:params => @params.merge({:page => n})),
          :url => "/markets/min_filter_lookup/?page=#{n}",
          :update => target,
          :before => "'filter_by_activity_indicator')",
          :success => "Element.hide('filter_by_activity_indicator')"
        html_options = {:href => url_for(:controller => controller,
=> action, :params => @params.merge({:page => n}))}

      logger.debug "pagination_links html_options:
      logger.debug "pagination_links controller: #{controller.inspect}"
      logger.debug "pagination_links prefix: #{prefix.inspect}"

      link_to_remote(n.to_s, options, html_options)

    if plinks
      "Page: #{plinks}"


This topic is locked and can not be replied to.