```ruby
class DashboardsController < ApplicationController
  before_action :authenticate_user!

  def show
    @posts = Post.all
  end
end
```

Use ActiveRecord's includes finder to avoid N+1 problem
user
```ruby
class DashboardsController < ApplicationController
  before_action :authenticate_user!

  def show
    @posts = Post.all.includes(:user)
  end
end
```
assistant