Project

General

Profile

Actions

Defect #13008

closed

Usage of attribute_present? in UserPreference

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

Status:
Closed
Priority:
Normal
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Hi,

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

>> User.new.pref
#<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,
Thomas

Actions #1

Updated by Etienne Massip almost 12 years ago

  • Target version set to Candidate for next minor release
Actions #2

Updated by Jean-Philippe Lang over 11 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.

Actions

Also available in: Atom PDF