Guest User

Untitled

a guest
Jun 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. class DealsController
  2. private
  3. def collection
  4. @collection ||= Deal.order(order_attributes).page(params[:page])
  5. end
  6.  
  7. def order_attributes
  8. DealOrderAttributes.build updated_at: :desc, params
  9. end
  10. end
  11.  
  12. class DealOrderAttributes
  13. def initialize attributes, params
  14. @attributes = attributes
  15.  
  16. @params = @params.fetch(:order, {})
  17. end
  18.  
  19. def build
  20. @attributes.merge params
  21. end
  22.  
  23. private
  24. def params
  25. #
  26. # build params
  27. #
  28. end
  29. end
Add Comment
Please, Sign In to add comment