The longer you hold c the higher you jump, that should get as close to the rail as possible before you dash. Then, in midair, hold the up and left keys at the same time and press x to dash diagonally. When you are close to the rail, hold z to to grab it.