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 query.

Also, build will only build the object without saving it.

So I think you are thinking something should be happening when it's not.

But I'm quite new to ruby/rails and although I'm developing an application
and trying to learn at the same time, it's difficult to grab all the nuances
of Rails. There's a lot to learn to become proficient.


On 14 March 2010 22:26, Max Williams <[email protected]> wrote:

> 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
> Grading#question_id then it works fine.  I'm just a little puzzled about
> the best way to go about validating question_id, since the default way
> seems to stop me building a question and gradings at once.
> --
> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>


-- 
100% naturally selected. 0% designed.

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to