Hello Rails fellas,
First of all I am a Rails n00b, only using it for about 2 weeks but I
already love it and bought the Agile Webdevelopment book.
I could set up my first rails application within minutes like it was
promised in the video.
Now I have run into a problem that I cannot solve my self, due to the lack
of understanding Ruby and of course Rails.
I have the following 2 classes:
class Exercise < ActiveRecord::Base
has_many :Answers
End
class Answer < ActiveRecord::Base
belongs_to :Exercise
validates_presence_of :text, :score
validates_numericality_of :score
End
Now I want to prepare a form in a view in which the user can add/change 4
answers for 1 exercise.
So I think the ''new'' action of the (exercise)controller should
create 4
answer objects and add them to the exercise. How do I do that? And how do I
have to create the form input fields for each answer?
I also want to make sure that each exercise only got 4 answers. I think that
could be validated somehow in the model using
''self.Answers.count''?
The database is already set up, ''answers'' table has a field
exercise_id.
Any help would be greatly appreciated,
Phil