Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
before_filter :foos, :only => "index"

def index
  if @search
    @foo = @search
  elsif @scope
    @foo = @search.foos
  else
    @foo = Foo.all
  end
end

private

def foos
  if params[:search]
    @search = Foo.search(params[:search])
  end
end