Hi I am trying to make a small survey app and started to get a little confused. So far i have survey.rb has_many :answers answer.rb belongs_to :survey So Survey will have many answers, and answer will belong to only one survey. This part works fine. Now i want to record survey results (you can only pick ONE answer, it will NOT be a multiple answer survey). To do this, as far as i know i should create anwsers_surveys table and setup proper habtm relations or create a new model and go with :through. Is this the way to go?, since i am not really trying to make a real habtm between surveys and answers but need to record the results. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
why not just have a score column in the answers table? On 7/16/07, Pawel Jur <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi > > I am trying to make a small survey app and started to get a little > confused. So far i have > > survey.rb > has_many :answers > > answer.rb > belongs_to :survey > > So Survey will have many answers, and answer will belong to only one > survey. This part works fine. Now i want to record survey results (you > can only pick ONE answer, it will NOT be a multiple answer survey). > > To do this, as far as i know i should create anwsers_surveys table and > setup proper habtm relations or create a new model and go with :through. > > > Is this the way to go?, since i am not really trying to make a real > habtm between surveys and answers but need to record the results. > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Pawel Jur wrote:> > Is this the way to go?, since i am not really trying to make a real > habtm between surveys and answers but need to record the results.Pawel, Step back from ActiveRecord for a bit and examine your problem domain. If a survey can have multiple answers and and answer can have multiple surveys then you have already answered your own question! i.e. you will need a link table either with the habtm (deprecated) or the first class model approach (:through) I write this response with the assumption that "answer" is equivalent to "result". If I am mistaken then please forgive the confusion. HTH ilan -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for responses! Chris Hall wrote:> why not just have a score column in the answers table?Yup. So simple solution and it fits just right for my problem. I gotta start drawing my models and relations on paper before i start making decisions i guess. Ilan, You are right if a survey could have multiple anwsers and answer can have multiple surveys but that''s not the case. Chris solution fits. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---