On Thu, Sep 24, 2015 at 4:18 PM Marco Antonio Almeida <[email protected]> wrote:
> Hi Colin, > > On Thu, Sep 24, 2015 at 1:30 PM Colin Law <[email protected]> wrote: > >> I am having a go, for the first time, at making a gem which is an >> engine. I have some javascript files which I have put in the >> gem/app/assets/javascript. I can access those from the app but only >> if I require them from the apps application.js. So if I have two js >> files in the gem, say f1.js and f2.js, then in the apps application.js >> I have to put >> //= require f1 >> //= require f2 >> >> I have not been able to find a way to avoid having to require them all >> individually. Is this possible? >> >> > What I usually do is something like this: > > Let's say that I have an engine called "my_engine", then I would create a > my_engine/app/assets/javascript/index.js which would have the content: > > //= require f1 > //= require f2 > > Then in the host app's application.js you can call > > // require my_engine > Sorry, I meant: "//= require my_engine" here. > This is actually a very neat trick that Rails have to load files inside a > folder. It will always look for an index.js file first. > > I hope this helps, > // Marco > > Colin >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsaW_Koe9NXxwUaiX7c5Fjep-6JLevzui7qEZECq9qE3A%40mail.gmail.com >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACMkcE550hODJOD_TnHY9zRMhv3LHtXWtD_Ta-Up5_eJ9vu%2BzQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

