Domanda

I've been following this post

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

I put the module into the lib directory and added the line to routes.rb like shown

When I do

rails s

I get an error, saying

uninitialized constant MyApp (NameError)

What's missing? Do I need to put the module some place else? Or let rails know somehow where it is?

È stato utile?

Soluzione

The author of that blogpost clarifies that problem in the comments:

You can add 'require "lib/api" to your config/routes.rb file or you can require automatically all files from lib directory by adding this line to your config/application.rb;

config.autoload_paths += %W(#{config.root}/lib)

Altri suggerimenti

Well ok, it's easy. I forgot to require 'myApp' in routes.rb....

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top