Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
When I am in Edit mode, the curve modifier doesn't work but
when I go to Object mode, the curve modifier works but the object (the rail) moves to the left.
Here is the file:
It's because the mesh and the curve haven't got the same origin point. Select the curve, press Shift+S-->Cursor to Selected. Then select your mesh and press Shift+S-->Selection to Cursor.
Required, but never shown