jacobtimm/kitchen_webapp — Issue #66: Grants :: Add filtering the Grants#index 
Author: edave
Created: 2012-02-01 23:17:37+00:00
State: open

Add filtering to the Grants that are shown in the Grants#index, so it only shows grants that are:
* submitted
* approved
* rejected

and

* Whole Foods
* FAR

You'll need some links along the top of the table for selecting which filters should be applied. This is typically done behind the scenes by passing params to the index action. ie, you might want to show which grants are approved, so you have a link to grants/?status=approved

And then in the index action you simply do a specialized query if that param is present:

```
if params[:status] != nil
Grant.where(:status => params[:status])
end
```

Since you can chain these things together, you don't want that except snippet, but something more like:

```
@grants = Grant.order_by(blah blah blah)
if params[:status] != nil
@grant = @grant.where(:status => params[:status])
end
```

So this way you'll be able to filter by both the status and the grant type.

It's also important when you're filtering to have the current filtered bolded and text (instead of a link). Relying on params in messy, so instead do this:

```
@grants = Grant.order_by(blah blah blah)
@status_filter = nil
if params[:status] != nil
@grant = @grant.where(:status => params[:status])
@status_filter = params[:status]
end
```

and then in the viewer code, do an if/else statement based off the value of that @status_filter