# Resources, controllers and models mapping

**URL:** <https://www.ruby-forum.com/t/resources-controllers-and-models-mapping/173862>\
**Category:** Rails\
**Created:** [August 17, 2009, 10:05am UTC](https://www.ruby-forum.com/t/resources-controllers-and-models-mapping/173862 "2009-08-17T10:05:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marmolin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71e660/32.png) [@marmolin](https://www.ruby-forum.com/u/marmolin)\
**Post date:** [August 17, 2009, 10:05am UTC](https://www.ruby-forum.com/t/resources-controllers-and-models-mapping/173862/1 "2009-08-17T10:05:15Z")

</div>

I have a person table and an event table (and many mores, but these  
two illustrates my problem)  
A person has many events  
I have a person resource and an event resource to manage the records  
in the tables  
Now I also want to manage person and events together in a more user  
friendly way.

My problem is now how to design the application ?

1. Should I have one person controller and one person resource, one  
event controller and on event resource and add a set of actions to the  
person and/or event controller to handle the user friendly management  
of persons and events ?

2. Should I have specifc controllers and resources representing  
different representations of persons and events, as the user friendly  
integrated representation and the table representation, each (if  
possible) limited to the seven basic actions (index, show, new , edit  
etc) ? E.g a person controller, an event controller and a person-event  
controller and corresponding resources!

3. Should I have a specific person-event controller with many specific  
actions, in addition to the person and event controller, that uses the  
same person and event resources?

---

<div class="post-metadata">

**Author:** ![marmolin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71e660/32.png) [@marmolin](https://www.ruby-forum.com/u/marmolin)\
**Post date:** [August 17, 2009, 11:12am UTC](https://www.ruby-forum.com/t/resources-controllers-and-models-mapping/173862/2 "2009-08-17T11:12:40Z")

</div>

ok you can do it person table function write in event controller you  
have specify it’s direction controller name and action name  
For. Ex.  
I have users and products  
i want to display product list in users folder then create  
file pro.html.erb and pro define in users controller it is work perfect.

---

<div class="post-metadata">

**Author:** ![marmolin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71e660/32.png) [@marmolin](https://www.ruby-forum.com/u/marmolin)\
**Post date:** [August 17, 2009, 11:21am UTC](https://www.ruby-forum.com/t/resources-controllers-and-models-mapping/173862/3 "2009-08-17T11:21:56Z")

</div>

Thanks for the advice  
However, I think all proposed solutions (1-3) will work, (I use  
solution 3 for the moment, that also works), but which one is the most  
RESTful one and which is to prefer from a software design point of  
view

On Aug 17, 11:12 am, Wap A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![marmolin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71e660/32.png) [@marmolin](https://www.ruby-forum.com/u/marmolin)\
**Post date:** [August 18, 2009, 5:54am UTC](https://www.ruby-forum.com/t/resources-controllers-and-models-mapping/173862/4 "2009-08-18T05:54:19Z")

</div>

Hans M. wrote:

> Thanks for the advice  
> However, I think all proposed solutions (1-3) will work, (I use  
> solution 3 for the moment, that also works), but which one is the most  
> RESTful one and which is to prefer from a software design point of  
> view

If I understand the original post correctly, the simplest and most  
easily RESTful solution would be 2.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![marmolin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71e660/32.png) [@marmolin](https://www.ruby-forum.com/u/marmolin)\
**Post date:** [August 18, 2009, 9:50am UTC](https://www.ruby-forum.com/t/resources-controllers-and-models-mapping/173862/5 "2009-08-18T09:50:37Z")

</div>

Marnen, I agree  
but as I had not found any guides recommending 2, I hesitated to take  
that approach  
I am just now implementing it supported by your recommendation

Thanks for all help

On Aug 18, 5:54 am, Marnen Laibow-Koser \<rails-mailing-l…@andreas-
