Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- maybe i have to rethink my situation:
- i have to store user profiles for every particular list like sorting/filtering and stuff.
- my idea:
- updating the profiles (when sorting) in a FilterController and redirecting to the particular Controller
- which represents the list (i.e. PeopleController.index) where the loading of the collection
- (with the updated filter conditions) and rendering takes place.
- right now my sorting looks like that:
- class PeopleController < ApplicationController
- def index
- respond_to do |format|
- format.html
- format.js{edit_profile(List.find_by_name 'people')} # the filter/profile updates are ajax calls
- end
- end
- private
- def filter
- @people = Person.find :all, :include=>[:towns, :documents], :limit=>@filter.items_per_page,
- :offset=>@filter.offset, :order=>@filter.order, :conditions=>@filter.conditions
- end
- end
- class ApplicationController < ActionController::Base
- def edit_profile list
- @filter = Filter.find_by_user_id_and_list_id session[:user_id], list.id
- if params[:page]
- @filter.paginate params[:page]
- @js_template = '/shared/paging/paginate'
- elsif params[:order] && params[:col]
- @filter.sort params[:col], params[:order]
- @js_template = '/shared/paging/select_row'
- elsif params[:items]
- @filter.itemize params[:items]
- @js_template = '/shared/paging/itemize'
- end
- filter # call PeopleController.filter
- end
- end
- that looks not very satisfying to me.
- that's why i think about putting the list stuff into an own controller
- for updating the filter/profile params. but then there is the issue
- to make the Filter.update action able to call the particular filter method of the particular
- Controller (i.e. PeopleController).
- do you have an idea?
Add Comment
Please, Sign In to add comment