Guest User

Untitled

a guest
Jun 22nd, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. ## Search feature allowing me to refuse the index action for multiple filters from different sections.
  2. ## There has to be a way to make this way way way way tidier.
  3. ## Give them sensible names, not just "s" "t" or "u", someone else may be maintaining this code one day.
  4. def index
  5. if params[:s]
  6. @events = Event.search(params[:s], :page => params[:page])
  7. flash[:notice] = "#{@events.size} events found"
  8. elsif params[:t]
  9. @events = Event.find_bysomething
  10. # set this in a before filter, should always be done via /users/name/events
  11. # Do a find for the user (params[:user_id]) and one for the category id too
  12. elsif @object
  13. @events = @object.events.paginate(:page => params[:page])
  14. # TODO: Define a to_s method on User model that calls the login method
  15. # TODO: Define a to_s method on Category model that calls the category method
  16. flash[:notice] = "Showing events for #{@object}"
  17. else
  18. @events = Event.paginate(:page => params[:page])
  19. end
  20. end
Add Comment
Please, Sign In to add comment