In my project there are n no. of questions... Following is an example of same... I have brought them via *loop* in my page, Q1: Question 1 a. answer 1 b. answer 2 c. answer 3 d. answer 4 Q2: Question 2 a. answer 1 b. answer 2 c. answer 3 d. answer 4 and so on... Submit(button) Also one option will be selected at a time, I have used radio buttons for answers Now the above data need to be stored in a table say answers_table where it will be saving question_id and answer_id....and on one submit action all the questions and answer should be inserted in database like this * answers_table* : id question_id answer_id 1 1 a 2 2 c I am facing this issue from since 2 days -- 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 https://groups.google.com/groups/opt_out.
On 8 August 2012 07:50, rubyrails9 <rubyrails9-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > In my project there are n no. of questions... Following is an example of > same... I have brought them via loop in my page, > Q1: Question 1 > a. answer 1 > b. answer 2 > c. answer 3 > d. answer 4 > > > Q2: Question 2 > a. answer 1 > b. answer 2 > c. answer 3 > d. answer 4 > > and so on... > > Submit(button) > > Also one option will be selected at a time, I have used radio buttons for > answers > Now the above data need to be stored in a table say answers_table where it > will be saving question_id and answer_id....and on one submit action all the > questions and answer should be inserted in database like this > > answers_table : > id question_id answer_id > 1 1 a > 2 2 c > > I am facing this issue from since 2 daysFirst, don''t call the table answer_table. Table name should be plural so if it has answers in then call it answers. Second, you have not actually asked a question that we can answer, just vaguely described the whole requirement. What exactly are you having problems with? Database design? The view? Controller code? Model code? You must ask specific questions that we can answer. Also you have not actually told us what models you have and what their releationships are (has_many, belongs_to etc.) Colin -- 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 https://groups.google.com/groups/opt_out.
On Aug 9, 2012, at 7:25 AM, Colin Law wrote:> On 8 August 2012 07:50, rubyrails9 <rubyrails9-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> In my project there are n no. of questions... Following is an example of >> same... I have brought them via loop in my page, >> Q1: Question 1 >> a. answer 1 >> b. answer 2 >> c. answer 3 >> d. answer 4 >> >> >> Q2: Question 2 >> a. answer 1 >> b. answer 2 >> c. answer 3 >> d. answer 4 >> >> and so on... >> >> Submit(button) >> >> Also one option will be selected at a time, I have used radio buttons for >> answers >> Now the above data need to be stored in a table say answers_table where it >> will be saving question_id and answer_id....and on one submit action all the >> questions and answer should be inserted in database like this >> >> answers_table : >> id question_id answer_id >> 1 1 a >> 2 2 c >> >> I am facing this issue from since 2 days > > First, don''t call the table answer_table. Table name should be plural > so if it has answers in then call it answers. > > Second, you have not actually asked a question that we can answer, > just vaguely described the whole requirement. What exactly are you > having problems with? Database design? The view? Controller code? > Model code? You must ask specific questions that we can answer. Also > you have not actually told us what models you have and what their > releationships are (has_many, belongs_to etc.) > > Colin >Secondly, this sounds very much like a problem that Ryan Bates covers in his two-part nested forms Railscast. He takes it a bit further than your example, in that the questions and the answers are completely configurable, rather than a fixed set of 4 answers. You might want to watch those for inspiration. The Rails version is a few versions back, but you should grasp the basics of how the relationships and the views are configured. Nothing about Rails 3 vs. 3.1 or 3.2 should change that. Walter> -- > 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@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.