Guest User

Untitled

a guest
Feb 21st, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. maybe i have to rethink my situation:
  2. i have to store user profiles for every particular list like sorting/filtering and stuff.
  3. my idea:
  4. updating the profiles (when sorting) in a FilterController and redirecting to the particular Controller
  5. which represents the list (i.e. PeopleController.index) where the loading of the collection
  6. (with the updated filter conditions) and rendering takes place.
  7.  
  8. right now my sorting looks like that:
  9. class PeopleController < ApplicationController
  10. def index
  11. respond_to do |format|
  12. format.html
  13. format.js{edit_profile(List.find_by_name 'people')} # the filter/profile updates are ajax calls
  14. end
  15. end
  16. private
  17. def filter
  18. @people = Person.find :all, :include=>[:towns, :documents], :limit=>@filter.items_per_page,
  19. :offset=>@filter.offset, :order=>@filter.order, :conditions=>@filter.conditions
  20. end
  21. end
  22.  
  23. class ApplicationController < ActionController::Base
  24. def edit_profile list
  25. @filter = Filter.find_by_user_id_and_list_id session[:user_id], list.id
  26. if params[:page]
  27. @filter.paginate params[:page]
  28. @js_template = '/shared/paging/paginate'
  29. elsif params[:order] && params[:col]
  30. @filter.sort params[:col], params[:order]
  31. @js_template = '/shared/paging/select_row'
  32. elsif params[:items]
  33. @filter.itemize params[:items]
  34. @js_template = '/shared/paging/itemize'
  35. end
  36. filter # call PeopleController.filter
  37. end
  38. end
  39.  
  40.  
  41. that looks not very satisfying to me.
  42. that's why i think about putting the list stuff into an own controller
  43. for updating the filter/profile params. but then there is the issue
  44. to make the Filter.update action able to call the particular filter method of the particular
  45. Controller (i.e. PeopleController).
  46.  
  47. do you have an idea?
Add Comment
Please, Sign In to add comment