One line command to clean up the trailing whitespace for a given project:
find . -name "*.rb" -type f -print0 | xargs -0 sed -i '' "s/[[:space:]]*$//"
This command will search for any files with the “rb” extension (Ruby files) and remove all trailing whitespace. This works in OSX, the command syntax might be different in Linux. Run this command from your project’s root.