I''m sorry, I originally posted this topic on Rails-Deployment, but it''s evidently the wrong area. I didn''t want to, did that on distraction, sorry :) Anyway, the original post was this below: Hello! I''m at my very first application in Rails, and I''m learning from Agile Development with Rails. I''m developing a web app that is run as a questionary. The idea is to create a database of questions (like 50), but use only like 10-15 each session, for each user. You can start the questionary only if you give your email address(validatates_presence_of). The point I''m wondering about is : since the answers are multiples and the sessions too, how can I keep track about whose belong certains answers? Shall I haven''t a pool of mixed answers? I was thinking about a migration with 16 slots (email, and 15 slots for each answer), could that work? I know it''s not exactly in the DRY logic, but in this way I''ll have a complete table, with which I could also calculate how many correct answer the user did, and statistics stuff like that. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wednesday, May 25, 2011 8:53:14 AM UTC-6, Ruby-Forum.com User wrote:> > I''m sorry, I originally posted this topic on Rails-Deployment, but it''s > evidently the wrong area. > I didn''t want to, did that on distraction, sorry :) > > Anyway, the original post was this below: > > Hello! > I''m at my very first application in Rails, and I''m learning from Agile > Development with Rails. >Welcome!> I''m developing a web app that is run as a questionary. > The idea is to create a database of questions (like 50), but use only > like 10-15 each session, for each user. > You can start the questionary only if you give your email > address(validatates_presence_of). > > The point I''m wondering about is : since the answers are multiples and > the sessions too, how can I keep track about whose belong certains > answers? Shall I haven''t a pool of mixed answers? > I was thinking about a migration with 16 slots (email, and 15 slots for > each answer), could that work? I know it''s not exactly in the DRY logic, > but in this way I''ll have a complete table, with which I could also > calculate how many correct answer the user did, and statistics stuff > like that. >Have you considered a structure such as: tables: questions (id, ...) answers (id, question_id, result_id, ...) results (id, email, ...) With... class Question < ActiveRecord::Base has_many :answers end class Answer < ActiveRecord::Base belongs_to :question belongs_to :result end class Result < ActiveRecord::Base has_many :answers end With this setup, you''d create a Result once a user gives you a valid email address (this could include checking if there is already a "result" from that email address). Then, your main questionnaire form loads a random set of Question instances (10-15) and, using them, renders your form(s) to ask them. As responses come in, you create/validate Answer instances that are linked to the current Result (represents the client''s questionnaire session) and the proper Question. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks very much! I''ll mess around with the code and I''ll let you know :) -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I''ve got an issue :how can I pick datas from a controller to another controller''s view? For example, how can I show a Question in the Answer''s index.html.erb? If i write <%= @questions.question %> on Answer''s index.html.erb, it doesn''t recognize the method, even if I previously wrote on the Question''s model. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
hmmm not really sure if I understand your question but here goes.. class AnswerController < ApplicationController def index @questions = Question.find(:all) end end If you have this code on your controller then the reason why it doesn''t recognize your method is because @questions here is an Array of Questions. So you have to loop through your array and display each question. So i think you have to do this on your index.html.erb <% @questions.each do |q| %> <%= q.question %> <% end %> -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
It was this, so the method index had to be copied exactly how it is to another controller in order to can list another controller''s array. Right! Thank you very much :) -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.