# Models more than Databases

**URL:** <https://www.ruby-forum.com/t/models-more-than-databases/173680>\
**Category:** Rails\
**Created:** [August 13, 2009, 9:45am UTC](https://www.ruby-forum.com/t/models-more-than-databases/173680 "2009-08-13T09:45:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmckinstry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pmckinstry](https://www.ruby-forum.com/u/pmckinstry)\
**Post date:** [August 13, 2009, 9:45am UTC](https://www.ruby-forum.com/t/models-more-than-databases/173680/1 "2009-08-13T09:45:14Z")

</div>

Hi Guys,

I would like some advice - I am new to Rails although not new to  
development. I have read numerous rails tutorials - however they all  
seem to build around forms interacting with a database. My question is  
how do models/controllers work when it goes beyond just adding things  
into databases?

For instance if I was to build a hotel booking engine, and I want to  
build out the ‘search’ functionality. The search functionality has 3  
basic elements.

1. Store the Users search requirements (e.g. destination, dates, rooms)  
in a table - this obviously is easy with rails (based on a users search  
form).
2. Perform a search against a 3rd party XML feed.
3. Store results in another database table.

My question is - what logic should go in a controller? and what should  
go in the models?

The user will enter data into a form, which will have a controller and  
action, so should there be a separate model for each of the 3 above ?  
and one controller? whats the best practice for doing such things or is  
there some good tutorials on how to architect a solution with rails?

Regards

Peter

---

<div class="post-metadata">

**Author:** ![pmckinstry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pmckinstry](https://www.ruby-forum.com/u/pmckinstry)\
**Post date:** [August 13, 2009, 11:17am UTC](https://www.ruby-forum.com/t/models-more-than-databases/173680/2 "2009-08-13T11:17:40Z")

</div>

If I were you, then I would think this way. I am assuming that your  
users are just unregistered site visitors.

1. Make a search controller and a searches model to store user queries
2. Make a searchresult model to store results
3. make searchresult belongs to search.

personally, i would not store search results to a table unless there is  
a specific need to do so. After all, same query @ different times would  
produce different result sets.

I would consider the entities such as user, 3rd party feed as models and  
the search as an interaction between those entities.

I will watch this topic to learn other’s expert opinions.
