Models more than Databases

0 views
Skip to first unread message

Pete Moran

unread,
Aug 13, 2009, 3:45:14 AM8/13/09
to rubyonra...@googlegroups.com
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
--
Posted via http://www.ruby-forum.com/.

Rails List

unread,
Aug 13, 2009, 5:17:40 AM8/13/09
to rubyonra...@googlegroups.com
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.

Reply all
Reply to author
Forward
0 new messages