I recommend adding self-censorship of authorization, such as CanCan, which allows you to establish whether a user has access to certain things (for example, edit an order, view the order, etc.). This can come in handy in many ways; you might want to have admin pages (to add new products, say) that customers should never have access to.
Once you do this, you can restrict access to the customer so that they can view or edit their own orders. In CanCan, you create a class called ability.rb that looks something like this:
class Ability include CanCan::Ability def initialize(user) user ||= User.new
This bit about can [:read, :update], Order, :user_id => user.id means that the user (non-admin) can read or update the order if order.user_id == user.id "(that is, the current user ID).
source share