Ideas for bracing a bed's side rail
Bed joist seem to not suit to the job here. Different kind of structure work. Your vertical element here works now as cantilever, while in former role (as a ladder as I suppose) it was supported as a continuous beam, which part was hanging up (if your bed is the upper one) or was to be tied as end of that ladder (if your bed was the lower one). Similar tensions, yes, but distributed differently .  

I have two suggestions:  


Use your two bolts, but with metal plates.
Your bolts probably worked too much on the wooden element's structure, and became loose through time. Try to put metal plates (regular steel plates that carpenters use with wood structures) between the bolt/nut and wood, use double nut. That would help to distribute the load from the steel bolt to the wood more 'per area' (crudely speaking) and avoid local deformations. A double nut may help prevent the first nut from unscrewing itself.  
Your idea with metal bracket is good.
Using a clamp-like metal element wide enough (to make a torque) and steel plates (small ones would do) on the interior side of the bed is a good option. If you can't find that kind of shape, just buy simple perforated steel carpenter plates (as in suggestion no. 1) long enough and bend them to suit your desired shape.   


If you can't visualize anything from my text wall (sorry about that), I may try to produce some drawings, but I need time with that. Also, more answers - more choices. I encourage other DIY-ers to post their answers, too.