cannot load such file — lib/api grape in rails 3.2.3

Showing 1-5 of 5 messages
cannot load such file — lib/api grape in rails 3.2.3 Maria Serrano Cáceres 7/3/12 3:09 AM
I am trying run grape gem in my rails 3.2.3 app.

I'm following this tutorial:

http://martinciu.com/2011/01/mounting-grape-api-inside-rails-application.html

but I get this error:

    cannot load such file -- lib/api

I have added the config.autoload_paths += %W(#{config.root}/lib) in my application.rb file.

Also I have added require "lib/api" to my routes.rb file

**What's missing?**
Re: cannot load such file — lib/api grape in rails 3.2.3 Daniel Doubrovkine 7/3/12 5:44 AM
In rails you shouldn't need to do the 'require' in routes.rb if the location of your api.rb is in the autoload_paths. If you place api.rb into lib, it should "just work" since lib is already autoloaded in Rails. What error(s) are you getting withotu any require or autoload_paths changes?
Re: cannot load such file — lib/api grape in rails 3.2.3 Maria Serrano Cáceres 7/3/12 5:56 AM
If I remove the require "lib/api" from routes.rb I get this error:

uninitialized constant MyApp

Thank you!

El martes, 3 de julio de 2012 14:44:25 UTC+2, Daniel Doubrovkine escribió:
Re: cannot load such file — lib/api grape in rails 3.2.3 Daniel Doubrovkine 7/3/12 7:02 AM
Is lib/api a folder or lib/api.rb file? The file names and the class names should match in ruby, so if you have MyApp, it should be in my_app.rb and it should be on the load path.
Re: cannot load such file — lib/api grape in rails 3.2.3 Maria Serrano Cáceres 7/3/12 7:29 AM
Thank you. This was the problem. The module name should match in ruby with the file names. The problem was fixed for me :D.

In the tutorial http://martinciu.com/2011/01/mounting-grape-api-inside-rails-application.html appear:

#lib/api.rb

this term leads to confusion and is incorrect.

Thank you!

El martes, 3 de julio de 2012 16:02:55 UTC+2, Daniel Doubrovkine escribió: