# Polymorphic assosciations - still the way in Rails 2.0.x

**URL:** <https://www.ruby-forum.com/t/polymorphic-assosciations-still-the-way-in-rails-2-0-x/124745>\
**Category:** Rails\
**Created:** [January 2, 2008, 5:19am UTC](https://www.ruby-forum.com/t/polymorphic-assosciations-still-the-way-in-rails-2-0-x/124745 "2008-01-02T05:19:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jawosis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f04885/32.png) [@jawosis](https://www.ruby-forum.com/u/jawosis)\
**Post date:** [January 2, 2008, 5:19am UTC](https://www.ruby-forum.com/t/polymorphic-assosciations-still-the-way-in-rails-2-0-x/124745/1 "2008-01-02T05:19:23Z")

</div>

I store a lot of information concerning blogs, events, books, bla  
bla…

So I have a lot of database tables including the same fields: url,  
user\_id, subject, comment…

So I decided to use polymorphic assosciations.

Is this still the prefered way in 2.0.x or does Rails 2.0.x offers me  
a easier, faster and more preferable way to do this?

By the way, isn’t it much easier to do all the search stuff with only  
one table? Perhaps it would not be so fast, but easier?!

Thanx

---

<div class="post-metadata">

**Author:** ![jawosis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f04885/32.png) [@jawosis](https://www.ruby-forum.com/u/jawosis)\
**Post date:** [January 2, 2008, 5:25am UTC](https://www.ruby-forum.com/t/polymorphic-assosciations-still-the-way-in-rails-2-0-x/124745/2 "2008-01-02T05:25:48Z")

</div>

I dont think that Rails 2.0 has any new ways to do this.

What did you mean by the searching?

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![jawosis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f04885/32.png) [@jawosis](https://www.ruby-forum.com/u/jawosis)\
**Post date:** [January 2, 2008, 5:29am UTC](https://www.ruby-forum.com/t/polymorphic-assosciations-still-the-way-in-rails-2-0-x/124745/3 "2008-01-02T05:29:18Z")

</div>

> What did you mean by the searching?

Let’s say a visitor wants to search the whole webseite for  
“activerecord”. Then I have to query all tables (blogs, books,  
forums) … and the showing the results. When all these things are  
stored in only ONE table things a much easier to handle.

---

<div class="post-metadata">

**Author:** ![jawosis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f04885/32.png) [@jawosis](https://www.ruby-forum.com/u/jawosis)\
**Post date:** [January 2, 2008, 6:02am UTC](https://www.ruby-forum.com/t/polymorphic-assosciations-still-the-way-in-rails-2-0-x/124745/4 "2008-01-02T06:02:01Z")

</div>

On 2 Jan., 05:46, “Ryan B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Storing them all into one table sounds complicated, but I understand what  
> you’re trying to achieve.

🙂

> I don’t think that it’s possible to put all that information into the one  
> table without over complicating things.  
> Have you heard of acts\_as\_ferret? That’s pretty good for searing.

Yes, I heard of it but never used it. I will give it a try.

Thanx

---

<div class="post-metadata">

**Author:** ![jawosis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f04885/32.png) [@jawosis](https://www.ruby-forum.com/u/jawosis)\
**Post date:** [January 2, 2008, 5:46am UTC](https://www.ruby-forum.com/t/polymorphic-assosciations-still-the-way-in-rails-2-0-x/124745/5 "2008-01-02T05:46:49Z")

</div>

Storing them all into one table sounds complicated, but I understand  
what  
you’re trying to achieve.

I don’t think that it’s possible to put all that information into the  
one  
table without over complicating things.

Have you heard of acts\_as\_ferret? That’s pretty good for searing.

On Jan 2, 2008 2:59 PM, Jochen K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![jawosis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f04885/32.png) [@jawosis](https://www.ruby-forum.com/u/jawosis)\
**Post date:** [January 2, 2008, 8:11am UTC](https://www.ruby-forum.com/t/polymorphic-assosciations-still-the-way-in-rails-2-0-x/124745/6 "2008-01-02T08:11:41Z")

</div>

On Jan 1, 8:18 pm, Jochen K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I store a lot of information concerning blogs, events, books, bla  
> bla…
> 
> So I have a lot of database tables including the same fields: url,  
> user\_id, subject, comment…

Three letters: D, R, and Y. 🙂

I would definitely factor that data out into its own model. Your  
searches will be faster, since you’ll be querying one table instead of  
X many tables.

///ark
