Hi Rim;

Any chance you could throw up a Gist for us to have a look at?
(http://gist.github.com/)

I reckon one of us will nail it if you could put up your models, the
controller you're going through and the form you're using it submit
the data.

Cheers,
Matta

On Wed, Dec 1, 2010 at 8:10 PM, Rimian Perkins <[email protected]> wrote:
> Hi,
>
> Thanks Jeff & Darcy.
>
> I've set the attribute to accessible but neither validating :user or :user_id 
> works.
>
> I'm getting closer to understanding it. Perhaps I should be running a 
> debugger to watch what's going on. It's a bit of a black box.
>
> Cheers,
> Rim
>
>
>
>
> -----------------------------------------
> Rimian Perkins
> http://www.rimian.com.au
> [email protected]
> http://twitter.com/rimian
> 0411 436 480
>
>
>
>
> On 30/11/2010, at 11:01 PM, Darcy Laycock wrote:
>
>> To clarify further,
>>
>> validates :user_id, :presence => true
>>
>> needs to instead be:
>>
>> validates :user, :presence => true
>>
>> Since the user is set usually but the actual id isn't yet. The id is
>> added to the record
>> when it's saved to the db / persisted.
>>
>> Along the same lines, you need to ensure you use something like
>> @user.socks.build(...) or manually set the user (If you need to let it
>> be set in the form from a choice
>> of multiple users, also possibly user_id as mentioned by Jeff).
>>
>> On Nov 30, 7:00 pm, Darcy Laycock <[email protected]> wrote:
>>> Try validating presence of user instead of user_id and it shouldn't be an 
>>> issue.
>>>
>>> On 30/11/2010, at 6:56 PM, Rimian Perkins <[email protected]> wrote:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>> Hi All,
>>>
>>>> I've created two models, user and socks where a user has many socks. Then, 
>>>> I created the migration but when I create a new user and save a new sock, 
>>>> the user_id is nil and the validation fails.
>>>
>>>> I'm really at a loss on how to debug this as it all seems like magic to 
>>>> me. I'm using devise for user authentication stuff, I don't know if that 
>>>> matters or not.
>>>
>>>> This might help:http://pastebin.com/HSYzPTGU
>>>
>>>> Can anyone point me in the right direction? I'm just staring at my code 
>>>> wondering what to do. I think I might be missing something.
>>>
>>>> Cheers,
>>>> @Rimian
>>>
>>>> --
>>>> You received this message because you are subscribed to the Google Groups 
>>>> "Ruby or Rails Oceania" 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 
>>>> athttp://groups.google.com/group/rails-oceania?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Ruby or Rails Oceania" 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/rails-oceania?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ruby or Rails Oceania" 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/rails-oceania?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" 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/rails-oceania?hl=en.

Reply via email to