I just changed from a normal has_many :blogs, belongs_to :user
relationship to a has_many through relationship. I created a new
model (subscription) and belongs_to'd it both blog and user, and set
up their has_many :subscriptions and their respective through
association. However, now when I go to create a new blog, I keep
getting a "User can't be blank" error. In my blog's create action,
I'm doing:
current_user.blogs.create
Is that the problem? Somehow the current_user's id isn't matching up
to the user_id column in the subscriptions model? It mapped correctly
before. I thought I might not have to pass in the current user, so I
tried:
Blog.create
but I got the same error, "User can't be blank".
I then thought maybe I had to allow its attr_accessible for some
strange reason, but still no dice. What am I doing wrong?
Big thanks in advance.
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment