ActiveModel::MissingAttributeError for association #4989

pedroteixeira opened this Issue Feb 10, 2012 · 5 comments


None yet

3 participants


Simple example to reproduce:
#rails 3.2.1
#config.active_record.mass_assignment_sanitizer = :strict

class Model < ActiveRecord::Base
belongs_to :user
end => nil)
results in ActiveModel::MissingAttributeError: can't write unknown attribute `author' => nil)
works fine.

This is exception is pretty bad since breaks tons of code.. any suggestions?

Ruby on Rails member

Does the same exception occur if you pass a user object in rather than nil?

Also, it seems you're trying to write a user parameter, but your exception says:

can't write unknown attribute `author'

Is this the full code to reproduce the problem?


yes, it ocurrs when passing any object. sorry for the type, the exception should have say 'user'.
even for this example, AR requires a database, and proper table to run.


can I help you fix this bug? I actually need rails 3.2 for some new features, but this breaks too much code. It also seems that when passing :assoc_id instead of :assoc in the constructor, presence validation does not work correctly.


@pedroteixeira Is this still occurring?



I actually did change my code to overcome the exceptions I was facing. So not sure. I guess we can close this, since no one else is reporting this issue. Next week, I'll try with the example again in my code and let you know. thanks anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment