On 2 September 2015 at 17:26, Aditi Thakur <a.thakur73...@gmail.com> wrote: > I am designing a rails application in which there is model named race_timing > which store the timings of students participate in different events.On view > page names of student according to selected event and age group is displayed > for entering the time taken by each individual to complete the > race.Currently I am storing the student_id and their corresponding timing in > an array as I want to submit multiple entries on single submit and it is > working properly. But now I want to display only 8 students at a time from > the array and store their corresponding timings but i am not getting a > proper way to do so. Can anyone suggest some solution??
Whenever you find yourself storing an array you are almost certainly doing it wrong. I suggest Student has_many race_timings RaceTiming belongs_to Student belongs_to Race Race has_many race_timings Each race_timing record contains student_id, race_id and timing data You can also say Student has_many races through race_timing and Race has_many students through race_timing if those would be useful If you have a race in @race for example, the timings for the race are @race.race_timings and the students are @race.students, and for any given timing you can say race_timing.race or race_timing.student. There is no reason that you cannot create multiple timings records in one submit, which I suggest would be to the race controller, as you are submitting timings for the race. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLuLT_vHmx0Mgv_x%3DaDuEcmmGBgTCFV2rUfKEFtrF9FTiA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.