Skip to content

Instantly share code, notes, and snippets.

@Mikr0Tik
Created September 26, 2008 07:51
Show Gist options
  • Save Mikr0Tik/13064 to your computer and use it in GitHub Desktop.
Save Mikr0Tik/13064 to your computer and use it in GitHub Desktop.
# towns_controller.rb
def show
@town = Town.find_by_id params[:id], :include=>:town
if_object @town do
@result_list = result_list_of :person, 'middle_age'
@nested_resource = :town
@people = Person.paginate :per_page=>@result_list.items_per_page,
:page=>@result_list.page,
:include=>Person.reflections.keys,
:order=>Person.sort_clause(@result_list.attribute_result_list),
:conditions=>{:female=>true}
respond_to do |format|
format.html
format.js
end
end
end
# people_controller.rb
before_filter :find_town
def find_town
@town = Town.find_by_id params[:town_id], :include=>:town if params[:town_id]
@result_list = result_list_of :person, 'middle_age'
@nested_resource = :town
@people = Person.paginate :per_page=>@result_list.items_per_page,
:page=>@result_list.page,
:include=>Person.reflections.keys,
:order=>Person.sort_clause(@result_list.attribute_result_list),
:conditions=>{:female=>true}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment