Guest User

Untitled

a guest
May 26th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. index.html.erb:
  2.  
  3. Filters:
  4. <% form_tag '', :id => 'filter_form' do %>
  5. <%= select (nil, "project_id", Project.find(:all).collect {|p| [ p.name, p.id ] },
  6. {:prompt => "Select a Project"}) %>
  7. <%= select (nil, "sprint_id", Sprint.find(:all).collect {|s| [ s.scheduled, s.id ] },
  8. {:prompt => "Select a Sprint"}) %>
  9. <%= select (nil, "user_id", User.find(:all).collect {|u| [ u.name, u.id ] },
  10. {:prompt => "Select a User"}) %>
  11. <% end %>
  12. <%= observe_form :filter_form,
  13. :frequency => 0.5,
  14. :update => 'display',
  15. :url => {:action=>'filter'},
  16. :with => [ :project_id, :sprint_id, :user_id ] %>
  17.  
  18. <div id='display'>
  19. </div>
  20.  
  21. INSIDE THE CONTROLLER:
  22.  
  23. def filter
  24. @tasks = Task.find( :all, :conditions => { :project_id => params[:project_id],
  25. :sprint_id => params[:sprint_id] } )
  26. render :update do |page|
  27. page.replace_html 'display', :partial => 'display'
  28. end
  29. end
Add Comment
Please, Sign In to add comment