I'm trying to follow Michael Hartl's Ruby on Rails tutorial and I'm currently stuck on ch 11. I don't know how to solve these errors:

```
1) Error:
UsersIndexTest#test_index_as_admin_including_pagination_and_delete_links:
NoMethodError: undefined method `microposts' for nil:NilClass
    app/controllers/users_controller.rb:14:in `index'
    test/integration/users_index_test.rb:12:in `block in <class:UsersIndexTest>'

2) Error:
UsersIndexTest#test_index_as_non-admin:
NoMethodError: undefined method `microposts' for nil:NilClass
    app/controllers/users_controller.rb:14:in `index'
    test/integration/users_index_test.rb:29:in `block in     <class:UsersIndexTest>'

```

The problem code in

```
app/controllers/users_controller.rb

```

is line 14, or `@microposts = @user.microposts.paginate(page: params[:page])`. The tests started failing after I added it.

```
 def index
    @users = User.paginate(page: params[:page])
    @microposts = @user.microposts.paginate(page: params[:page])
 end

```

I thought there was a problem with the associations, but I have

```
class Micropost < ActiveRecord::Base
belongs_to :user
.
.
.
end

```

and

```
class User < ActiveRecord::Base
  has_many :microposts
  .
  .
  .
end

```

Some of my tests also work with @user.micropost

```
class MicropostTest < ActiveSupport::TestCase

  def setup
   @user = users(:michael)
   @micropost = @user.microposts.build(content: "Lorem ipsum")
 end

 test "should be valid" do
    assert @micropost.valid?
 end

```

So I have no clue as to what is wrong. If anyone can help that would be awesome.