# Hi..Guys new plugin again

**URL:** <https://www.ruby-forum.com/t/hi-guys-new-plugin-again/113810>\
**Category:** Rails\
**Created:** [September 5, 2007, 6:49am UTC](https://www.ruby-forum.com/t/hi-guys-new-plugin-again/113810 "2007-09-05T06:49:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhonny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/919ad9/32.png) [@jhonny](https://www.ruby-forum.com/u/jhonny)\
**Post date:** [September 5, 2007, 6:49am UTC](https://www.ruby-forum.com/t/hi-guys-new-plugin-again/113810/1 "2007-09-05T06:49:19Z")

</div>

Hi…

Guys new plugin again

Foreign Key Associations is a plugin that automatically creates  
associations based on foreign-keys. The associations are created at  
runtime-ie. as your ActiveRecord models are loaded-so they will always  
be up-to-date.

For example, given a foreign-key from a customer\_id column in an  
orders table to an id column in a customers table, the plugin  
creates:

Order.belongs\_to :customerCustomer.has\_many :orders  
If there is a uniqueness constraint-eg unique index-on a foreign-key  
column, then the plugin will creates a has\_one instead of a has\_many.

For example, given a foreign-key from an order\_id column with a  
uniqueness constraint in an invoices table to an id column in an  
orders table, the plugin creates:

Invoice.belongs\_to :orderOrder.has\_one :invoice  
Additionally, if there is a position column in the child table, the  
parent association will be created with an order clause.

For example, given a foreign-key from a order\_id column in an  
order\_lines table containing a position column, to an id column in a  
orders table, the plugin creates:

OrderLine.belongs\_to :ordersOrder.has\_many :lines, :order =\> :position  
The plugin also supports the creation of has\_and\_belongs\_to\_many  
associations.

For example, given the tables product\_product\_categories with foreign-  
keys to both the product and product\_categories tables, the plugin  
creates:

Product.has\_and\_belongs\_to\_many  
:categoriesProductCategory.has\_and\_belongs\_to\_many :products  
And finally, notice that in one of the previous examples, the  
association name used for the Order.has\_many is :lines and  
not :order\_lines. More specifically, the plugin removes the prefix  
from has\_many and has\_one associations if the the name of parent class  
forms a proper prefix of the child class name.

The plugin fully supports and understands the following active-record  
configuration properties:

config.active\_record.pluralize\_table\_names  
config.active\_record.table\_name\_prefix  
config.active\_record.table\_name\_suffix

Installation  
EDGE  
To install using SVN:  
ruby script/plugin install  
svn://rubyforge.org/var/svn/redhillonrails/trunk/vendor/plugins/foreign\_key\_associations

or using HTTP:  
ruby script/plugin install  
[http://www.redhillonrails.org/svn/trunk/vendor/plugins/foreign\_key\_](http://www.redhillonrails.org/svn/trunk/vendor/plugins/foreign_key_)

---

<div class="post-metadata">

**Author:** ![jhonny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/919ad9/32.png) [@jhonny](https://www.ruby-forum.com/u/jhonny)\
**Post date:** [September 5, 2007, 8:21am UTC](https://www.ruby-forum.com/t/hi-guys-new-plugin-again/113810/2 "2007-09-05T08:21:26Z")

</div>

Stop flooding the group with these posts.

---

<div class="post-metadata">

**Author:** ![jhonny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/919ad9/32.png) [@jhonny](https://www.ruby-forum.com/u/jhonny)\
**Post date:** [September 5, 2007, 9:04am UTC](https://www.ruby-forum.com/t/hi-guys-new-plugin-again/113810/3 "2007-09-05T09:04:29Z")

</div>

good work buddy,

flood away…you did the hard work and should be able to get some  
acknowledgment for it

announcing developments like this is just what this mailing list is  
for…

high fives all round…down low for Rein H.

---

<div class="post-metadata">

**Author:** ![jhonny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/919ad9/32.png) [@jhonny](https://www.ruby-forum.com/u/jhonny)\
**Post date:** [September 5, 2007, 9:09am UTC](https://www.ruby-forum.com/t/hi-guys-new-plugin-again/113810/4 "2007-09-05T09:09:30Z")

</div>

Neither this nor any of the 15 other posts this person has made in a  
15 minute span have been their work.

---

<div class="post-metadata">

**Author:** ![jhonny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/919ad9/32.png) [@jhonny](https://www.ruby-forum.com/u/jhonny)\
**Post date:** [September 5, 2007, 9:13am UTC](https://www.ruby-forum.com/t/hi-guys-new-plugin-again/113810/5 "2007-09-05T09:13:30Z")

</div>

Besides, the link to the plugin (that he didn’t write) isn’t even  
valid.

---

<div class="post-metadata">

**Author:** ![jhonny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/919ad9/32.png) [@jhonny](https://www.ruby-forum.com/u/jhonny)\
**Post date:** [September 5, 2007, 11:16am UTC](https://www.ruby-forum.com/t/hi-guys-new-plugin-again/113810/6 "2007-09-05T11:16:11Z")

</div>

Rein H. wrote:

> Besides, the link to the plugin (that he didn’t write) isn’t even  
> valid.

I agree with Rein H., stop flooding…

“One question at the time, and wait till you get answer before asking a  
new one”

---

<div class="post-metadata">

**Author:** ![jhonny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/919ad9/32.png) [@jhonny](https://www.ruby-forum.com/u/jhonny)\
**Post date:** [September 5, 2007, 12:22pm UTC](https://www.ruby-forum.com/t/hi-guys-new-plugin-again/113810/7 "2007-09-05T12:22:57Z")

</div>

sorry guys, I had not seen all the other posts…

stop flooding foo

---

<div class="post-metadata">

**Author:** ![jhonny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/919ad9/32.png) [@jhonny](https://www.ruby-forum.com/u/jhonny)\
**Post date:** [September 6, 2007, 5:19am UTC](https://www.ruby-forum.com/t/hi-guys-new-plugin-again/113810/8 "2007-09-06T05:19:48Z")

</div>

For the record, I’m all for announcing open source developments here.  
I was subscribed to ruby forge for over a year before it got to be too  
much. I plan on making a few such announcements myself. 🙂

However, I’m less keen on announcing other people’s hard work and  
conveniently forgetting to give them credit.

Rein

---

<div class="post-metadata">

**Author:** ![jhonny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/919ad9/32.png) [@jhonny](https://www.ruby-forum.com/u/jhonny)\
**Post date:** [September 5, 2007, 2:40pm UTC](https://www.ruby-forum.com/t/hi-guys-new-plugin-again/113810/9 "2007-09-05T14:40:39Z")

</div>

I was 2 seconds from marking all of Jhonny’s posts as spam when I  
noticed  
that they are all on topic…

Stop flooding

Jason
