简体   繁体   中英

Create method looking for a method not called

When I try to create a Collaborator object in the console, I get the following error:

1.9.3p194 :001 > Collaboration.create(user_id: 14593, member2_id: 14594)
   (0.1ms)  SAVEPOINT active_record_1
   (0.2ms)  ROLLBACK TO SAVEPOINT active_record_1
NoMethodError: undefined method `member1_id' for #<Collaboration:0x000001031c4040>

The thing is, the method member1_id is not called by the create method of the Collaboration controller (obviously it is also not used a parameter in the function call). The line

grep -r "member1" .

Returns migration files and development logs only, no MVC code.

Where is Rails finding a call to the "member1_id" method?

Edit:

Simple error, see my answer

Simple answer here, I put the following line in my Collaboration model

validates_uniqueness_of :member1_id, scope: :member2_id

Rewriting it to replace member1 with user

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM