Closed jahio closed 4 years ago
I've got a very simple API I'm trying to build mounted inside an otherwise empty Rails 6 app. The code is in app/api/name/api.rb for just a small part of the app, but the bulk of the code presently lives in other files. I do not want to mix my entire app's code into one giant file. How can I get this Grape app working, inside Rails, and not have all my stuff in one several-thousand line Ruby file?
see https://github.com/ruby-grape/grape#modules
Related: How can I also see my Grape-defined/specific routes inside this Rails app? rake routes doesn't exactly help here, just showing that the Grape app is mounted at /.
https://github.com/ruby-grape/grape#describing-and-inspecting-an-api and there was a couple of gems for integration with rails, try to use search
Related: How can I also see my Grape-defined/specific routes inside this Rails app? rake routes doesn't exactly help here, just showing that the Grape app is mounted at /.
https://github.com/ruby-grape/grape#describing-and-inspecting-an-api and there was a couple of gems for integration with rails, try to use search
I've got a very simple API I'm trying to build mounted inside an otherwise empty Rails 6 app. The code is in
app/api/name/api.rb
for just a small part of the app, but the bulk of the code presently lives in other files. I do not want to mix my entire app's code into one giant file. How can I get this Grape app working, inside Rails, and not have all my stuff in one several-thousand line Ruby file?A screenshot of the directory structure and existing code:
Note that this exact same Grape code itself did work in a previous version of this app I had built without Rails. I ran into some very unusual Rails-specific crap when using ActiveRecord and decided, "screw it, I'll just go full Rails for this" to get around it, and I copied over the code verbatim following the directions, but now I'm running into this oddity.
I've also tried having all three files in the
app/api
directory next to each other; onlyapi.rb
gets picked up. If I explicitlyrequire_relative './users.rb'
or something like that I get a complaint from Zeitwork about expecting the files to be named a certain way which is why I organized them by directory and class inheritance as seen in the screenshot.Related: How can I also see my Grape-defined/specific routes inside this Rails app?
rake routes
doesn't exactly help here, just showing that the Grape app is mounted at/
.