简体   繁体   中英

Creating a Ruby gem with JavaScript files (Rails 3)

I'm planing to create a simple Ruby gem. The functionality is depending on some .js files. My plan is to install the gem via Github.

My questions are:

  1. should I write a generator to copy the js files?
  2. what is the best place to keep the js files (is it vendor/assets/javascripts?)
  3. how to write test cases for this (rspec2) ?

I'm using Rails > 3, Ruby 1.9.x and Ruby 2.x.

We can easily use Javascripts library in ruby in following way -

1) We can put all js libararies in Vendor section and for their use we can define then application.js in following way

//= require datatable-pagination . .

2) Next if you want to use your own javascript then u put them into your assets folder and use then application.js in above way.

3) And if you want to make your own js library, then you can put your js libarary in lin folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM