title: Why doesn't :readonly => true work on a belongs_to association?
body: <p>I have the following model:</p>
  
  <pre><code>class Question &lt; ActiveRecord::Base
  
    belongs_to :user, :readonly =&gt; true
  
  end
  </code></pre>
  
  <p>I would expect that the :readonly => true attribute would prevent the user from being changed i.e.</p>
  
  <pre><code># assume we've set up user_1, user_2 and question 
  # and that question.user == user_1
  
  question.user = user_2
  question.save
  question.reload 
  question.user == user_2 # true - why?
  </code></pre>
  
  <p>Why is this true - I expected that :readonly=> true would prevent this attribute from being changed after initial creation? If it doesn't then what does the :readonly option actually do?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Using <code>attr_readonly</code> will give the non-changeability (immutability?) that I was looking for. </p>
  
  <pre><code>class Question &lt; ActiveRecord::Base
  
    belongs_to :user
    attr_readonly :user_id
  
  end
  </code></pre>
  
  <p>The only problem with it is that it never raises an exception when you try to change the attribute so it's easy to get bugs out of silent fails.</p>