You can also get one of those bed rails that you use to keep your toddlers from rolling out of bed.
I have seen them in various lengths, up to around 60". This was an idea I had last year for storage in our Class C's overhead bunk, but have not bought one yet.
If you have an inflatable mattress, it might not work, but if you have a regular mattress like a Class C has, the rail just tucks under the mattress.