# Plugin Initialization

**URL:** <https://www.ruby-forum.com/t/plugin-initialization/114823>\
**Category:** Rails\
**Created:** [September 17, 2007, 6:33pm UTC](https://www.ruby-forum.com/t/plugin-initialization/114823 "2007-09-17T18:33:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [September 17, 2007, 6:33pm UTC](https://www.ruby-forum.com/t/plugin-initialization/114823/1 "2007-09-17T18:33:54Z")

</div>

Hi,

I was curious if there was a more appropriate way to execute a “one-  
time” initialization of a plugin–

Basically, I’ve created a plugin that utilizes a javascript file-- I  
want to copy this j/s file into the public/javascripts/ directory  
immediately upon adding it your project.

Is there a standard mechanism for doing this?

Unless someone has a better idea, my approach was going to be to write  
code in init.rb that checks to see if these files already exist in the  
public directory, and if not, to copy them in (from within the plugin  
directory structure).

Anyone got a better idea?

-John

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [September 17, 2007, 6:52pm UTC](https://www.ruby-forum.com/t/plugin-initialization/114823/2 "2007-09-17T18:52:58Z")

</div>

IIRC, you can have install.rb in your plugin which will be run when  
someone does script/plugin install

But of course, it won’t work if someone just copies the plugin or use  
piston/svn directly.

On 9/17/07, John T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there a standard mechanism for doing this?
> 
> >

–  
Cheers!

- Pratik  
[http://m.onkey.org](http://m.onkey.org)

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [September 17, 2007, 6:57pm UTC](https://www.ruby-forum.com/t/plugin-initialization/114823/3 "2007-09-17T18:57:59Z")

</div>

Thanks for the response. Yeah, we’re using Piston here to manage our  
plugins, and that was certainly a concern of mine (no initialization,  
that is).

I guess I could just do both (install.rb and init.rb)!

-John
