paul h wrote:
> Hi Max,
>
> Have you tried:
>
> @question = Question.create(attributes)
> @grading = @question.gradings.build(more_attrs)
>
> Using create instead of new will save the Object to the DB first, and
> hence:
>
Hi Paul. Yes, i know that, thanks - in this situation i would do
grad
Hi Max,
Have you tried:
@question = Question.create(attributes)
@grading = @question.gradings.build(more_attrs)
Using create instead of new will save the Object to the DB first, and
hence:
@question[:id] will/should/may not be nil when building your gradings.
I'm six months in to Rails, don't
I don't have your original mail and am not sure of the model but question_id
is a foreign key.No? You are checking for the existence of it before it has
been created, that is why it's failing, no?
validate methods validate the data before its saved. Unless I'm missing
something from your original
Hi Anthony, thanks.
I'm not using the rails-supplied nested attributes methods here, though
maybe i should. I'm effectively hand-rolling my own, so i create a
question and some associated objects (eg a grading in this case) at the
same time, from a single form. When i drop the validation on
Rob Lacey wrote:
> I'd say the best way to deal with this is never validate for a
> association_id
>
> #validates_presence_of :question_id
> validates_presence_of :question
>
> would be better.
Hi Rob!
I played with this already, and got a surprising result:
>>@question = Question.new(attribu
5 matches
Mail list logo