# Calling find()

**URL:** <https://www.ruby-forum.com/t/calling-find/67876>\
**Category:** Rails\
**Created:** [February 14, 2006, 10:27am UTC](https://www.ruby-forum.com/t/calling-find/67876 "2006-02-14T10:27:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julian\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@Julian\_I](https://www.ruby-forum.com/u/Julian_I)\
**Post date:** [February 14, 2006, 10:27am UTC](https://www.ruby-forum.com/t/calling-find/67876/1 "2006-02-14T10:27:48Z")

</div>

Hello,  
Nobody reply on my previous post, so from one day i`m asking on the irc  
channel, and no response too. I try to generate scaffold code, on my  
problem, to see how it handle this, but the result is the same …

When I do generate scaffold Products/Category  
I get controller with name Products::Category and model with name  
Category,  
Now in the same application if I do generate scaffold  
Phonebook/Category, my

Previous category model is replaced.

When I manually create model Products/Category and Phonebook/Category, I  
cannot use the model or truly I doesn`t know how to use it.

Please, provide some solution on my minor problem.

---

<div class="post-metadata">

**Author:** ![Julian\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@Julian\_I](https://www.ruby-forum.com/u/Julian_I)\
**Post date:** [February 14, 2006, 11:53am UTC](https://www.ruby-forum.com/t/calling-find/67876/2 "2006-02-14T11:53:53Z")

</div>

You’ll need to merge them manually - what problems arose when you tried  
doing this?

Why are you using “Products/Category” and “Phonebook/Category”? Perhaps  
you  
really just need three domain objects - Phonebook, Product, and Category  
with some relationships in between. For instance:

class Product \< ActiveRecord::Base  
belongs\_to :category  
end  
class Phonebook \< ActiveRecord::Base  
belongs\_to :category  
end  
class Category \< ActiveRecord::Base  
has\_many :products  
has\_many :phonebooks  
end

Not sure if that’s helpful but perhaps with more info I can be more  
helpful.

- Byron

---

<div class="post-metadata">

**Author:** ![Julian\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@Julian\_I](https://www.ruby-forum.com/u/Julian_I)\
**Post date:** [February 14, 2006, 3:13pm UTC](https://www.ruby-forum.com/t/calling-find/67876/3 "2006-02-14T15:13:10Z")

</div>

Hello,

I`m building application, which have features user to have Phonebook and  
Contacts, each of these features can be categorized in

categories and subcategories. That`s why I need to have  
Phonebook/Category  
and Contacts/Category, if someone can provide better

approach, please share it.

I`m trying to escape the 3 object solution, because I doesn`t want to  
load  
up my Phonebook controller with stuffs about the category. I want

to separate category somehow from the Phonebook, because Phonebook will  
be  
responsible only for the numbers mainly. I`m not sure is this right.

* * *

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Byron  
Saltysiak  
Sent: Tuesday, February 14, 2006 12:54 PM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Rails] Calling find()

You’ll need to merge them manually - what problems arose when you tried  
doing this?

Why are you using “Products/Category” and “Phonebook/Category”? Perhaps  
you  
really just need three domain objects - Phonebook, Product, and Category  
with some relationships in between. For instance:

class Product \< ActiveRecord::Base  
belongs\_to :category  
end  
class Phonebook \< ActiveRecord::Base  
belongs\_to :category  
end  
class Category \< ActiveRecord::Base  
has\_many :products  
has\_many :phonebooks  
end

Not sure if that’s helpful but perhaps with more info I can be more  
helpful.

- Byron

On 2/14/06, Julian I. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Hello,  
Nobody reply on my previous post, so from one day i`m asking on the irc  
channel, and no response too. I try to generate scaffold code, on my  
problem, to see how it handle this, but the result is the same …

When I do generate scaffold Products/Category  
I get controller with name Products::Category and model with name  
Category,  
Now in the same application if I do generate scaffold  
Phonebook/Category, my

Previous category model is replaced.

When I manually create model Products/Category and Phonebook/Category, I  
cannot use the model or truly I doesn`t know how to use it.

Please, provide some solution on my minor problem.

* * *

Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

---

<div class="post-metadata">

**Author:** ![Julian\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@Julian\_I](https://www.ruby-forum.com/u/Julian_I)\
**Post date:** [February 14, 2006, 3:13pm UTC](https://www.ruby-forum.com/t/calling-find/67876/4 "2006-02-14T15:13:16Z")

</div>

The Product::Category is an code organizational grouping not a data  
relationship. You should definitely be using three objects related to  
each  
other as above.

This also gives you the ability to pull up a category and see all the  
Products or Phonebooks that relate to it.

I don’t think that performance should be your primary concern at this  
point.  
Just get the code to work now in an understandable way and then do some  
profiling to find where the problems are if you’re not happy with the  
performance.

- Byron
