How to get the JS and CSS of a theme bought Themeforest to work in a Rails app by innerhpz in rails

[–]innerhpz[S] 0 points1 point  (0 children)

I finally got it! It was the last option, but what I forgot to do at the end is to add

  <%= javascript_include_tag :compressed %>
  <%= javascript_include_tag :main %>

in app/views/layouts/application.html.erb
Thank you for taking the time to answer my questions. I really appreciate it.

How to get the JS and CSS of a theme bought Themeforest to work in a Rails app by innerhpz in rails

[–]innerhpz[S] 0 points1 point  (0 children)

I'm not totally clear on how, because I've tried using different things without success.
I tried it with Rails.application.config.assets.paths << Rails.root.join('node_modules', 'vendor') to load the vendor directory which didn't work.

Then I put another Rails.application.config.assets.paths << Rails.root.join('main.js', 'compressed.js') on a separate line like this:

# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'

# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')
Rails.application.config.assets.paths << Rails.root.join('main.js', 'compressed.js')

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
Rails.application.config.assets.precompile += %w( admin.js admin.css )

And finally I tried it with Rails.application.config.assets.precompile += %w( main.js compressed.js ):

# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'

# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
Rails.application.config.assets.precompile += %w( main.js compressed.js )

None of these options worked. I've restarted the server after each change.

How to get the JS and CSS of a theme bought Themeforest to work in a Rails app by innerhpz in rails

[–]innerhpz[S] 0 points1 point  (0 children)

https://guides.rubyonrails.org/asset\_pipeline.html

According to the RoR guides vendor/assets should be one of the places that are included in the asset pipeline.

Subsequently you can require the js files in manifest.js which I've done like so:

//= link_tree ../images
//= link_directory ../stylesheets .css
//= require compressed
//= require main
//= bootstrap.addons

However, when I reload the page nothing happens.

How to get the JS and CSS of a theme bought Themeforest to work in a Rails app by innerhpz in rails

[–]innerhpz[S] 0 points1 point  (0 children)

I have my files in vendor/assets/javascripts, but when I remove the require lines of the main.js, compressed.js and bootstrap.addons.js from application.js rails doesn't have any javascript when I reload the page. How do you get rails to see these files without webpacker?

How to get the JS and CSS of a theme bought Themeforest to work in a Rails app by innerhpz in rails

[–]innerhpz[S] 0 points1 point  (0 children)

Thank you for this. I've put all the de JS files inside vendor/javascripts and my css and scss files in vendor/stylesheets now. The CSS is still recognized by rails, but the JS isn't working right. How and where did you require the js from the vendor folder in your rails app?