Joining tables?

Hi guys,

Just wondering if anyone can help me, im quite a newbie to ruby. i have
developed an application(Fitness site) which allows users to register
and obtain a free fitness programme based on the info they have entered
when registering. this is were my problem lies i need to connect the
fitness programme to the users table in the database and use some sort
of algrothim to select the correct fitness programme for them based on
the age they entered when registering. any ideas??

link to website http://funkyfitness.heroku.com/

Hi,

The best method is the ActiveRecord relationship.

In the users model you place the code has_many :programs and in the
progrm model put this belongs_to :users
So, in the controller you can use the find method with parameters.

I hope this help you!

Hi,
Thanks for your help, just stuck on using the find method with
parameters in the controller, i want to have 3 different fitness
program’s based on age so under 18 redirect to a specific program,
between 18 - 40 redirect to a another program and over 40 redirect to a
last program… any ideas? Age is one of the columns already in the
database.