Comments (7)
The gem did not work for me so here's what I did:
Using particles.js in RoR project
- Include app.js(if you have custom config), particles.js in assets/javascripts
- Include /= require particles.js in application.js
- Include style.css for details regarding background color/canvas
- Go to the view which will handle particles.js (in my case homepage which means, view/welcome/homepage) and add
<%= stylesheet_link_tag 'style'%>
<div id="particles-js"></div>
<%= javascript_include_tag 'particles', 'app'%>
Add the following to config/initializers/assets.rb
Rails.application.config.assets.precompile += %w( particles.js )
Rails.application.config.assets.precompile += %w( app.js )
from particles.js.
To use Rails use:
/* app/assets/javascripts/application.js */
//= require particles.js.js
/* your code */
/* id in html, "path/to/json" */
particlesJS.load('id', 'assets/config.json');
<!-- app/views/controller/index.html.erb -->
<div id="id"></div>
source : README
from particles.js.
I made an example Rails app here if anyone is interested: https://github.com/excid3/particlesjs-rails-example
from particles.js.
The gem doesnt work... and also all of these solutions are messy for an RoR app. You should install the npm package and call the package from the JS folder.. Webpack will precompile for you instead of sacrificing performance in assets.rb
from particles.js.
@JaeggerFrank
Probably it's rails-assets configuration issue, do other rails-assets gems works for you?
running bundle
you should see this in output
Fetching gem metadata from https://rails-assets.org/...
Fetching version metadata from https://rails-assets.org/..
gem should be added in Gemfile like this
source 'https://rails-assets.org' do
gem 'rails-assets-particles.js'
end
from particles.js.
@sandhilt will it wok in production environment too?? as i am calling particlesJs inside application.js
from particles.js.
@godiaz I can't seem to get the gem to work either...
from particles.js.
Related Issues (20)
- decrease the movement speed
- Can't interact with the page content - Elementor HOT 1
- Particle.js overlaps everything HOT 1
- Push particles based on variable change in a seperate function HOT 3
- Render single frame for prefers-reduced-motion HOT 1
- How to disable interactivity HOT 1
- s
- Problem with particles.js 2023 HOT 1
- Particles dont interact while hovering or clicking HOT 1
- Uncaught ReferenceError: Stats is not defined in Wordpress HOT 1
- idk
- how to use config file HOT 1
- particals js error
- Documentation HOT 2
- Make code compatible with ES5 strict mode HOT 2
- How can I reset the particles to initial position?
- Particles as a background
- New particles duration?
- Hold down instead of on click on push animation?
- Rotate is not working?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from particles.js.