Normally, helpers are used to get logic out of a view.  In this case since we're dealing purely with model logic, I think we could safely move this code into the `AssignmentExercise` model by adding a `prev` and a `next` method to it.

Since `AssignmentExercise`s are numbered, we can also avoid querying for the entire array of assignment exercises in an exercise with something like this untested code:

    def next
      AssignmentExercise.where{number == my{number}+1}.where{assignment_id == my{assignment_id}}
    end

Save us a query and the query we run only has to return one record instead of all AEs for an assignment.

Note that the curly bracket `where` syntax and the `my` call come from a gem called [squeel](https://github.com/activerecord-hackery/squeel) which gives some niceties on top of ActiveRecord.  

If you didn't want to duplicate the `.where{assignment_id == my{assignment_id}}` code between the `prev` and `next` calls, you could introduce a `scope` for it:

    scope :peers, where{assignment_id == my{assignment_id}

    def next
      AssignmentExercise.peers.where{number == my{number}+1}
    end

And now that I've written all of this, I have realized that these `prev` and `next` methods should be added to `lib/acts_as_numberable.rb`, which is the library that manages the numbered nature of this model.  

If you look at the top of `app/models/assignment_exercise.rb` you'll see the call that makes a bunch of `number`-related things work in this class:

    acts_as_numberable :container => :assignment

Since the `acts_as_numberable` library already knows the container object (as well as the number field), it can just implement `prev` and `next` on its own (and that way they'll be available to all numbered models.

Maybe take a look at the lib file -- if it makes sense where you'd put the code, go ahead and do it.  If not immediately clear, we can chat after scrum tomorrow.