Terry, the short version is to find someone to sand blast it and then follow that up quickly with automotive primer to keep the rust from coming back. Then you can wait a little while to spray paint it or have it painted. You may want to use an automotive body putty or filler like Bondo to fill ny big holes.
Others will tell you that naval jelly will turn the rust back to iron. It's probably your choice but I prefer getting rid of the rust.
If you need them, you can get bed rails at your home center or bedding stores. You might want to do this first to be sure that the rails fit to connect the frame together.
As always, read and follow the label directions on any product that you use.