Coder Social home page Coder Social logo

Working with Rails about particles.js HOT 7 OPEN

vincentgarreau avatar vincentgarreau commented on July 29, 2024
Working with Rails

from particles.js.

Comments (7)

mantrarush avatar mantrarush commented on July 29, 2024 3

The gem did not work for me so here's what I did:

Using particles.js in RoR project

  1. Include app.js(if you have custom config), particles.js in assets/javascripts
  2. Include /= require particles.js in application.js
  3. Include style.css for details regarding background color/canvas
  4. 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.

sandhilt avatar sandhilt commented on July 29, 2024 1

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.

excid3 avatar excid3 commented on July 29, 2024 1

I made an example Rails app here if anyone is interested: https://github.com/excid3/particlesjs-rails-example

from particles.js.

godiaz avatar godiaz commented on July 29, 2024 1

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.

vmotsak avatar vmotsak commented on July 29, 2024

@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.

GokuDBZ avatar GokuDBZ commented on July 29, 2024

@sandhilt will it wok in production environment too?? as i am calling particlesJs inside application.js

from particles.js.

pschfr avatar pschfr commented on July 29, 2024

@godiaz I can't seem to get the gem to work either...

from particles.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.