There isn’t an easy root method available for users of current Sony Xperia Ray, and the process itself makes you go away from the benefits of having a rooting device. Firmware 4.0.2.a.0.42 build can be rooted without the need of unlocking the bootloader which is a great boon for newbies and the process itself is very easy.
1. Download SE Xperia Ray 4.0.2.a.0.42 build from here.
2. Download Flashtool from here.
3. Install Flashtool. Also, install the driver file which can be found inside C:\Flashtool\drivers (if you don’t have already).
4. Rename the file downloaded in step 1 from Xperia Ray (ST18i)_4.0.2.A.0.42_CE.ftf.7z to Xperia Ray (ST18i)_4.0.2.A.0.42_CE.ftf and put it inside C:\Flashtool\firmware.
5. Connect your phone via USB. Make sure you have checked with Unknown Resources (Settings > Applications > Unknown Resources) and USB Debugging (Settings > Applications > Unknown Resources > Development > USB Debugging) and unckeck MTP Transfer mode (go to Settings > Sony Ericsson > Connectivity and disable select UBS transfer mode instead of MTP Transfer mode)
6. Open Flashtool and click ‘Flash’ symbol. See the image below.
7. This will bring-up a new window. Click ‘Flash mode’, see the image below.
8. Follow onscreen instructions where it will ask you to switch off Sony Ericsson Xperia Ray and plug it again (press down volume key while plugging).
9. If you followed all the above instructions correctly, you will have 4.0.2.a.0.42 as firmware on your device. Now, see the tutorial posted here to unlock your bootloader and install root on your device.