Rails 3 with Grape issue
-
16-06-2021 - |
Question
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?
Solution
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)
OTHER TIPS
Well ok, it's easy. I forgot to require 'myApp' in routes.rb....
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow