views:

27

answers:

0

I'm Rails newbie so this might be incredibly stupid question but I hope somebody finds the time to help me :)

I'm currently doing my first Rails 3 application with MongoDB. I have setup Devise for authentication and it's working great. I'm trying to create blog type of app so each registered user can post an article. Naturally user model has "many: posts" and post model has "belongs_to: user" but here's the problem: I don't want to have user_id as a field in the new post form for security reasons so how can I pass the current user to post model? I removed all fields related to user data from the form so now it doesn't seem to be able to get the data for user_id anywhere.

So how do I use Devise's current_user helper method to pass the correct user_id to post model for proper association?