3
votes

I am using Grape to build my API, and according to the documentation, I added the following lines to application.rb so that allapp/api` ruby scripts are added to the path, as well as allowing auto-reload for development mode:

config.paths.add "app/api", :glob => "**/*.rb"
config.autoload_paths += Dir["#{Rails.root}/app/api/*"]

I also added a piece of code in config/initializers as asked to. However, neither auto-reload nor the paths are working properly.

For the path, I need to explicitly add everything using require at the main API file that I am using (I separated my Grape files into files + directories under app/api. If I remove the require, I get:

NoMethodError    
undefined method `call' for V1:Module

The auto-reload is also not working at all. It does not auto-reload when I change something.

What am I missing here?

1
Post your app somewhere and email the Grape mailing list. There's an app in github.com/dblock/grape-on-rails that does all of this and has been tested to work.dB.

1 Answers

0
votes

If you split api into many files you need mount that parts. See documentation for modules

These don't have to be different versions, but may be components of the same API.

class APP::API < Grape::API
  mount APP::Groups
  mount APP::Users
end