assets issue in rails 6 for grape-swagger-rails - ruby-on-rails

grape-rails-swagger used to work fine with rails 5
but now with rails 6 lots of things have changed with webpacker now its giving error
Showing /home/faisal-nfl/.rvm/gems/ruby-2.6.2/gems/grape-swagger-rails-0.3.1/app/views/grape_swagger_rails/application/index.html.erb where line #7 raised:
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 even tried to follow instructions in error but same issue

Not sure why but, I had to add these at top of app/assets/config/manifest.js
//= link grape_swagger_rails/application.css
//= link grape_swagger_rails/application.js
so app/assets/config/manifest.js looks like this now
//= link grape_swagger_rails/application.css
//= link grape_swagger_rails/application.js
//= link_tree ../images
//= link_directory ../stylesheets .css
its working now

Related

ruby on rails style configuration issue

My ruby on rails app needed bootstrap and js, so I tried to add them.
Even though both styles are in the same folder, some of them are loading and some are not.
im getting
ActionController::RoutingError (No route matches [GET] "/lib/uniform.default.css")
and other css modules
i tried to add everything into my manifest.js but no luck
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link_tree ../../javascript .js
//= link_tree ../../../vendor/javascript .js
//= link_tree ../img
//= link_tree ../css
//= link_tree ../js
//= link_tree ../font
//= link bookmarklet.coffee
You need to create a lib folder in your app/assets/stylesheets, e.g.:
mkdir app/assets/stylesheets/lib
Then put your uniform.default.css file into this folder

RoR Spree Asset Differs on Production & Heroku

I'm tryin to solve this for nearly 2 days. I'm pretty mad at now.
I'm using Spree (latest version) with Rails 5. I'm trying to use W3's Shape template as theme. Css is ok and working fine but I can't manage to get workin javascript assets.
Here is my vendor/javascripts/spree/frontend/all.js
//= require jquery
//= require jquery_ujs
//= require accounting.min
//= require shape/all ---> As you can see i require my template's assets
//= require_tree .
//= require spree/frontend/spree_auth
//= require spree/frontend/spree_i18n
And here is the assets/javascripts/shape/all.js
//= require_tree .
And inside that Shape folder, there are javascript assets.
When in development mode, everything works perfect. There is no issue. But when i try to switch production mode or deploy to heroku, template's javascript assets does not included.
Thank you all.
Edit: For a temporary solution, I did include my problematic js assets by old classic html way. But still I'm really curios about how can this happen.

Rails Asset Pipeline not including same file in multiple manifests

This is my application.js:
//= require jquery
//= require jquery_ujs
//= require_tree .
//= stub subscriptions
It has always worked as expected and subscription.js is another file which is compiled separately.
If I add this line at the top of subscriptions.js:
//= require jquery
The subscriptions.js is compiled as expected and includes jQuery, but jQuery disappears from application.js: in the browser console I get errors like
ReferenceError: jQuery is not defined.
I cannot find a way to have jquery compiled/included in both the manifest files.
I use a development environment with Rails 4.2.4 + Puma and the default jquery-rails gem.
It's the expected behavior of the stub directive: not only subscriptions but also all its dependencies will be stubbed.
The only solution is to avoid using require_tree and stub.

how to effectively organize vendor css and js files togheter in rails assets

(I'm new both to Rails and SO, so excuse if I'm not doing it right)
I am trying to adapt a regular third-party web template in my rails 4 application. I have a vendor folder with other files and subfolders like bootstrap.js, Nivo-slider and Isotope which contain both .css and .js files.
So I moved all files and subfolders to vendor/assets and included //= require_tree ../../../vendor/assets/ in my application.js, as recommended here. So my application.js looks like
//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require turbolinks
//= require_tree ../../../vendor/assets/
//= require_tree .
And in my layout file:
<%=stylesheet_link_tag "application.css" -%>
<%=javascript_include_tag "application" -%>
when I execute it on my server I get Sprockets::FileOutsidePaths exception:
Showing /home/valle/RoR/grifo/app/views/layouts/application.html.erb where line #25 raised:
/home/valle/RoR/grifo/vendor/assets/bootstrap.js isn't in paths: /home/valle/RoR/grifo/app/assets/images, /home/valle/RoR/grifo/app/assets/javascripts, /home/valle/RoR/grifo/app/assets/stylesheets, /home/valle/RoR/grifo/lib/assets/circle-flip-slideshow, /home/valle/RoR/grifo/lib/assets/isotope, /home/valle/RoR/grifo/lib/assets/javascripts, /home/valle/RoR/grifo/lib/assets/jflickrfeed, /home/valle/RoR/grifo/lib/assets/magnific-popup, /home/valle/RoR/grifo/lib/assets/mediaelement, /home/valle/RoR/grifo/lib/assets/nivo-slider, /home/valle/RoR/grifo/lib/assets/owl-carousel, /home/valle/RoR/grifo/lib/assets/rs-plugin, /home/valle/RoR/grifo/lib/assets/stylesheets, /home/valle/RoR/grifo/lib/assets/twitterjs, /home/valle/.rvm/gems/ruby-1.9.3-p392/gems/modernizr-rails-2.7.1/vendor/assets/javascripts, /home/valle/.rvm/gems/ruby-1.9.3-p392/gems/turbolinks-2.2.2/lib/assets/javascripts, /home/valle/.rvm/gems/ruby-1.9.3-p392/gems/jquery-rails-3.1.0/vendor/assets/javascripts, /home/valle/.rvm/gems/ruby-1.9.3-p392/gems/coffee-rails-4.0.1/lib/assets/javascripts, /home/valle/.rvm/gems/ruby-1.9.3-p392/bundler/gems/twitter-bootstrap-rails-663760e67b80/app/assets/fonts, /home/valle/.rvm/gems/ruby-1.9.3-p392/bundler/gems/twitter-bootstrap-rails-663760e67b80/app/assets/images, /home/valle/.rvm/gems/ruby-1.9.3-p392/bundler/gems/twitter-bootstrap-rails-663760e67b80/app/assets/javascripts, /home/valle/.rvm/gems/ruby-1.9.3-p392/bundler/gems/twitter-bootstrap-rails-663760e67b80/app/assets/stylesheets, /home/valle/.rvm/gems/ruby-1.9.3-p392/bundler/gems/twitter-bootstrap-rails-663760e67b80/vendor/assets/stylesheets
I thought Sprockets would take all js or css files in all assets folders, precompile, unify and minify them, but now it seems I need to specify the path. How could I solve it?
Besides, is it a problem not to have separated javascript and css folders in vendors?
in rails 4 they have removed vendor folder,so,assets will not server from vendor.
in that Rails.application.config.assets.paths not contains vendor,if you want you have to add the path like
in config/application.rb
config.assets.paths << "#{Rails.root}/vendor/assets"
Update application.js file as
//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require turbolinks
//= require_tree .
//= require otherJsFiles
And in application.css file require other css file as
*= require otherCssFiles
Require each js and css file in application.js and application.css file placed in vendor/assets.

Bootstrap drowdown works locally but not in heroku

Currently working on the Ruby on Rails tutorial (railstutorial.org) and in Chap 8. you make a dropdown menu using bootstrap classes for signed in users.
To make this work the book says to include
//= require jquery
//= require jquery_ujs
//= require bootstrap
in your application.js file.
This does not work locally or on heroku.
However:
//= require bootstrap
//= require jquery
//= require jquery_ujs
works locally, not on heroku. This also creates a ton of error messages in the console (Uncaught TypeError: cannot read property 'fn' of undefined)
Every stack thread and googled page I go to says that bootstrap goes first in local and jquery first in production. Meanwile I'm pulling my hair out.
git hub: https://github.com/nelsonkhan/sample_app
heroku: https://guarded-shelf-3017.herokuapp.com/
you need to have all 4 of these:
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require_tree .
Make sure your assets are properly compiled when you deploy on heroku. Check here for more details: https://devcenter.heroku.com/articles/rails-asset-pipeline
Changing production.rb helped for me
config.assets.compile = true

Resources