Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Controller
@filters = {
:states => %w{active inactive all},
:owners => current_account.users,
:organisations => current_account.organisations,
}
# View
- form_tag projects_path, :method => :get, :id => 'filters' do
%h2 Customise view
%p
%label
State:
= filter_tag :state, @filters[:states], :value => :titleize
= select_tag :state, options_for_select(@filters[:states].collect{ |s| [s.titleize, s] }, params[:state])
%p
%label
Owner:
= filter_tag :owner_id, @filters[:owners], :prompt => 'All'
= select_tag :owner_id, options_for_select([['All', nil]] + @filters[:owners].collect{ |u| [u, u.id] }, params[:owner_id].to_i)
%p
%label
Client:
= filter_tag :organisation_id, @filters[:organisations], :prompt => 'All'
= select_tag :organisation_id, options_for_select([['All', nil]] + @filters[:organisations].collect{ |o| [o, o.id] }, params[:organisation_id].to_i)
%p.actions
= submit_tag 'Filter'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment