Project

General

Profile

Actions

Refactor #13971

closed

Change model.exists?(record) and .find(record) to use IDs

Added by Dominic Cleal almost 9 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Rails
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Rails 4.2 contains the following deprecation:

Deprecated passing Active Record objects to .find or .exists?. Call id on the objects first.

(http://edgeguides.rubyonrails.org/4_2_release_notes.html#active-record-deprecations)

This causes:

> Domain.find(Domain.first)
2016-03-01T12:35:12 [app] [W] DEPRECATION WARNING: You are passing an instance of ActiveRecord::Base to `find`. Please pass the id of the object by calling `.id`. (called from irb_binding at (irb):1)

All instances where we pass objects into .find etc, mostly in tests, need to be changed to call .id.

This happens a lot in functional tests when a User is passed into the session object, e.g.

delete :destroy, {:id => user}, set_session_user.merge(:user => users(:admin))

causes

DEPRECATION WARNING: You are passing an instance of ActiveRecord::Base to `find`. Please pass the id of the object by calling `.id`. (called from authenticate at /home/dcleal/code/foreman/foreman/app/controllers/concerns/foreman/controller/authentication.rb:10)
Actions #1

Updated by The Foreman Bot almost 9 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3256 added
Actions #2

Updated by Dominic Cleal almost 9 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #3

Updated by Dominic Cleal almost 9 years ago

  • Translation missing: en.field_release set to 136
Actions

Also available in: Atom PDF