# Rails plugin with Javascript file

**URL:** <https://www.ruby-forum.com/t/rails-plugin-with-javascript-file/111826>\
**Category:** Rails\
**Created:** [August 11, 2007, 7:14pm UTC](https://www.ruby-forum.com/t/rails-plugin-with-javascript-file/111826 "2007-08-11T19:14:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnlester](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@johnlester](https://www.ruby-forum.com/u/johnlester)\
**Post date:** [August 11, 2007, 7:14pm UTC](https://www.ruby-forum.com/t/rails-plugin-with-javascript-file/111826/1 "2007-08-11T19:14:43Z")

</div>

Hi, last question of the day (promise!!!)

I’m packaging up some work into a plugin. One of the parts is a  
javascript file currently in “public/javascripts”. I thought I’d be able  
to move it to “vendor/myplugin/public/javascripts” or  
“vendor/myplugin/javascripts” or even “vendor/myplugin/lib” but none of  
these worked.

Is it possible to have a “js” file in a plugin and, if so, how do I do  
it?

Uncortunately, Creating plugins isn’t mentioned in the Agile book and  
Google drew a blank to this particular question.

---

<div class="post-metadata">

**Author:** ![johnlester](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@johnlester](https://www.ruby-forum.com/u/johnlester)\
**Post date:** [August 13, 2007, 5:45pm UTC](https://www.ruby-forum.com/t/rails-plugin-with-javascript-file/111826/2 "2007-08-13T17:45:31Z")

</div>

Hey,

You may want to look at [http://www.activescaffold.com/](http://www.activescaffold.com/) plugin for where  
they  
keep a js file with in plugin directory.

-Jatinder

---

<div class="post-metadata">

**Author:** ![johnlester](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@johnlester](https://www.ruby-forum.com/u/johnlester)\
**Post date:** [August 16, 2007, 1:07pm UTC](https://www.ruby-forum.com/t/rails-plugin-with-javascript-file/111826/3 "2007-08-16T13:07:48Z")

</div>

> On 8/11/07, John L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Is it possible to have a “js” file in a plugin and, if so, how do I do  
> > it?

You might also want to look at the engines plugin (http://rails-  
[engines.org](http://engines.org)), which makes it trivially easy to include public assets  
in plugins and have them servable by your web server.

–  
James

---

<div class="post-metadata">

**Author:** ![johnlester](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@johnlester](https://www.ruby-forum.com/u/johnlester)\
**Post date:** [August 16, 2007, 1:50pm UTC](https://www.ruby-forum.com/t/rails-plugin-with-javascript-file/111826/4 "2007-08-16T13:50:22Z")

</div>

James A. wrote:

> You might also want to look at the engines plugin (http://rails-  
> [engines.org](http://engines.org)), which makes it trivially easy to include public assets  
> in plugins and have them servable by your web server.

This rails-engine looks like the answer. I shall try it out. Thanks!
