The upper railing for the closet in my daughters room wiggles. I went up into the attic to see why, and it seems like it's attached predominantly into the drywall ceiling - in some places with anchors, and in some places without anchors (?!).
(Sorry for the image quality, was balancing at a strange angle and trying to get enough light into the area).
What can I do to fix this situation? I'm sort of inclined to just unscrew the railing entirely, lay a 2x4 on top of the drywall and then screw the railing back in (e.g. so then screws go through the drywall into the 2x4). Do I need to support this 2x4 in some other way, by connecting to the joist (or is it a rafter)?

