Defect #13008

Usage of attribute_present? in UserPreference

Added by Thomas Löber over 9 years ago. Updated almost 9 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:


Category:Code cleanup/refactoring
Target version:2.3.3
Resolution:Fixed Affected version:2.2.2



when I enter in the Rails console, user_id is stored in the others hash.

#<UserPreference id: nil, user_id: nil, others: {"user_id"=>nil}, hide_mail: false, time_zone: nil>

Solution: In UserPreference#[] and UserPreference#[]= attribute_present? should be replaced by has_attribute?.

The current implementation also works because UsersController#create saves the user before creating the preference, so attribute_present? :user_id returns true.

Best regards,

Associated revisions

Revision 12126
Added by Jean-Philippe Lang almost 9 years ago

Fixed usage of #attribute_present? in UserPreference (#13008).

Revision 12127
Added by Jean-Philippe Lang almost 9 years ago

Merged r12126 from trunk (#13008).


#1 Updated by Etienne Massip over 9 years ago

  • Target version set to Candidate for next minor release

#2 Updated by Jean-Philippe Lang almost 9 years ago

  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Target version changed from Candidate for next minor release to 2.3.3
  • Resolution set to Fixed

Fixed in r12126 with a test, thanks for pointing this out.

Also available in: Atom PDF