You need to add ":user_id" to the attr_accessible line for Sock.  If
it's omitted, Rails will block the user_id from being set during
mass-assignment.  I'd bet that if you look in the server log for an
UPDATE or CREATE action that you'll see a line like "WARNING: Can't
mass-assign value to protected attribute user_id"

- Jeff

---
Jeff Casimir
Jumpstart Lab by Casimir Creative, LLC
http://jumpstartlab.com
@jumpstartlab on twitter



On Tue, Nov 30, 2010 at 9: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 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