Topic: what is the point of relationships in rails? ?

I get the idea of them "well I sure hope I do! "

Anyway, I have not seen any reason to have them yet .. they dont dynamicly return anything do they ? All of the tutorials I have seen for using them just has me entering l;ots of extra configurations ...

person has many movies... movies have many titles... Maybe I 'am' missing something...

Last edited by tripdragon (2006-08-29 19:33:15)

Re: what is the point of relationships in rails? ?

Are you asking why you have to define relationships in Rails after they are already defined in the database?

Railscasts - Free Ruby on Rails Screencasts

Re: what is the point of relationships in rails? ?

so you can do useful things with the data, for example, so you can do things like:-

<% for movie in person.movies %>
  <%= movie.title -%>(<a href="<%=movie.imdb_url -%>IMDB</a>)
<% end %>

And your page outputs a nice little list of all the movies that the user likes

Complex web apps are built on relationships, and while you *can* just write specific queries to get the relevant data from the database, Rails abstracts this out into common, simple relationship that allows you to deal with the data much more in a way we are used to in the real world - making it simpler to visualise, easier to work with and more fun to code. All of which are Good Things(TM)