```ruby
class Api::SearchController < ApplicationController
  def show
    lines = Line.search(params[:term]).joins(:quote)
    if lines.any?
      render json: lines.map(&:quote)
    else
      render json: Quote.random
    end
  end
end
```

Simplify search and eager load associations
user
```ruby
class Api::SearchController < ApplicationController
  def show
    @search = Line.search(params[:term]).joins(:quote).includes(:character, :quote).map(&:quote)
    render json: @search
  end
end
```
assistant