How to include a vendor multi-module JS library in Rails?

39 views
Skip to first unread message

Luís de Sousa

unread,
Aug 28, 2014, 4:03:11 AM8/28/14
to rubyonra...@googlegroups.com

Hello everyone,

I am trying to include a JS library (GeoExt) in an existing Rails application. Following the Asset Pipeline guide, I did:

  • Created the folder /vendor/assets/javascripts/GeoExt to where I copied all the JS modules.

  • Created the file /vendor/assets/javascripts/GeoExt/index.js containing the //= require_tree . directive.

  • In the application.js file included the directive //= require GeoExt.

With this setting I am getting a 404 error every time a module from this library is referenced. What am I doing wrong?

Thank you.

Colin Law

unread,
Aug 28, 2014, 4:23:11 AM8/28/14
to rubyonra...@googlegroups.com
I have not done exactly that. Does it work if you put GeoExt
immediately under assets so /vendor/assets/GeoExt?

Colin

Damjan Rems

unread,
Aug 28, 2014, 8:02:00 AM8/28/14
to rubyonra...@googlegroups.com
You probably have same problem that I was writing in this post.
https://www.ruby-forum.com/topic/5503104

Javascript library is trying to load modules in runtime. Your chance is
to place javascript files directly to the place (url) where they are
required. Look at the url in error and put javascript files there.

by
TheR

--
Posted via http://www.ruby-forum.com/.

Luís de Sousa

unread,
Sep 2, 2014, 8:39:23 AM9/2/14
to rubyonra...@googlegroups.com
Hi Colin,

No, moving the library a folder up doesn't not change the outcome.

Thank you,

Luís

Luís de Sousa

unread,
Sep 2, 2014, 8:46:34 AM9/2/14
to rubyonra...@googlegroups.com
Hi Damjan,

These URLs are point to /datasets/mass_import, a path that does not exist in this project:

http://localhost:3000/datasets/mass_import/GeoExt/data/reader/Wmc.js?_dc=1409661484402

If you are correct, then I a do not have much of an idea where to include the library.

Thank you,

Luís
Reply all
Reply to author
Forward
0 new messages