ruby-grape / grape-swagger-rails

Swagger UI as Rails Engine for grape-swagger gem.
MIT License
251 stars 197 forks source link

assets issue in rails 6 #96

Closed Faisal-nfl closed 4 years ago

Faisal-nfl commented 4 years ago

with rails 6, lot of things changed but not sure what I have to do, it gives error

Asset grape_swagger_rails/application.css was not declared to be precompiled in production. Declare links to your assets in app/assets/config/manifest.js.

//= link grape_swagger_rails/application.css and restart your server

I did this but same issue, not sure what else I have to do

dblock commented 4 years ago

This shouldn't be a problem. Somehow you're including the CSS/JS uncompressed from a subfolder instead of whatever the default inclusion happens with Railtie.

Faisal-nfl commented 4 years ago

@dblock thanks for response I created a sample project on github rails6_backend

its giving same error, have a look please. (swagger stuff is in the last commit)

UPDATE after adding these two lines in app/assets/config/manifest.js

//= link grape_swagger_rails/application.css
//= link grape_swagger_rails/application.js

now it started to work, now I just want to confirm that is it the right way OR I messed up something which forcing me to add these lines?

Faisal-nfl commented 4 years ago

For another project faced very same issue even after adding those lines in menifest.js after trying different stuff for hours it started to work by addling these lines at top of app/assets/config/manifest.js, its looks like this now

//= link grape_swagger_rails/application.css
//= link grape_swagger_rails/application.js
//= link_tree ../images
//= link_directory ../stylesheets .css
dblock commented 4 years ago

Looking at https://github.com/Faisal-nfl/rails6_backend/blob/master/app/assets/config/manifest.js it's pretty custom and doesn't include dependencies with require_tree .. I think your solution is a good one. I'd appreciate a better explanation for the README in the https://github.com/ruby-grape/grape-swagger-rails#enabling-in-a-rails-api-project section. Want to contribute?

Faisal-nfl commented 4 years ago

sure, I would love to. though I never contributed to such project. what I have to do

or anything else?

Faisal-nfl commented 4 years ago

@dblock I tried to explain it and generated pull request. have a look if ok? pull request