Skip to content

Commit c07095c

Browse files
committed
Fix tests failing on migration and primary key error
1 parent 264115a commit c07095c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

spec/db/migrate/10_create_users.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class CreateUsers < ActiveRecord::Migration
1+
class CreateUsers < ActiveRecord::Migration[4.2]
22
def change
33
create_table :users do |t|
44
t.string :name

spec/lib/active_model/association_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ class Group
132132
include ActiveModel::Associations
133133

134134
attr_accessor :name
135-
attr_reader :user_ids
135+
attr_reader :id, :user_ids
136136

137-
has_many :users
137+
has_many :users, primary_key: "id"
138138

139139
def [](attr)
140140
self.send(attr)
@@ -234,8 +234,8 @@ def []=(attr, value)
234234

235235
it "can define different class_name association" do
236236
class DiffClassNameHasManyGroup < Group
237-
attr_reader :member_ids
238-
has_many :members, class_name: "User"
237+
attr_reader :id, :member_ids
238+
has_many :members, class_name: "User", primary_key: "id"
239239
end
240240

241241
user = User.create(name: "joker1007")

0 commit comments

Comments
 (0)