Why does mounting a route in Rails fail with “uninitialized constant API”?

大兔子大兔子 提交于 2019-12-05 10:30:08

Try moving your API code's files from app/api to app/api/api.

From Grape's documentation:

Place API files into app/api. Rails expects a subdirectory that matches the name of the Ruby module and a file name that matches the name of the class. In our example, the file name location and directory for Twitter::API should be app/api/twitter/api.rb.

Thus the correct location for your API::Root class would actually be app/api/api/root.rb.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!