Chris Braddock on 21 Dec 2005 23:43:24 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PhillyOnRails] stuck ... help please


I'm having a problem with components & partials I'm hoping someone can chime
in on.

>From my (default) home_controller.rb, I'm using a render_component to call
an action (list_pending) in events_controller.rb.

The action contains a paginator and uses a partial to render it's html.  The
problem is that once I click on the "Next/Prev" links renderd in the home
view, I'm directed to a view in events.  I really want to stay on the home
view, call the component again with the correct page values propagated
through the list_pending action.

I think it just boils down to me not correctly using components or partials
or both.

Relevant code...

--- app/views/home/index.rhtml

<div id="EventsPending">
  <%= render_component :controller => "events", :action => "list_pending" %>
</div>

--- app/controllers/events_controller.rb

def list_pending
  @event_pages = Paginator.new(self, Event.count, 10, @params[:page])
  @events = Event.find :all,
                       :conditions => "status != 'approved'",
                       :limit => @event_pages.items_per_page,
                       :offset => @event_pages.current_page.offset
  # I've managed to make some ground here conditionally using
render(:template => "home/index") which fixes the view issue, but my links
still weren't working
end

--- app/views/events/list_pending.rhtml

<h3>Pending Events</h3>

<%= render :partial => "event_list" -%>


--- app/views/events/_event_list.rhtml
  
<% for event in @events %>
  # output events html
<% end %>

<%= link_to "Previous page", { :controller => "events", :action =>
"list_pending", :page => @event_pages.current.previous } if
@event_pages.current.previous %>
<%= link_to "Next page", { :controller => "events", :action =>
"list_pending", :page => @event_pages.current.next } if
@event_pages.current.next %> 

Thanks for any insight.

Chris


_______________________________________________
talk mailing list
talk@phillyonrails.org
http://lists.phillyonrails.org/mailman/listinfo/talk