Reputation: 6579
My model schema:
User
has_many :activities
has_many :companies through: :activities
Company
has_many :activities
has_many :users, through: :activities
Activity
belongs_to :user
belongs_to :company
Problem when I try to run current_user.activities.delete_all(["company_id=?", params[:id]])
or clear
or destroy
I get this error:
ArgumentError: wrong number of arguments (1 for 0)
from /home/rom/.rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/associations/collection_association.rb:156:in `delete_all'
from /home/rom/.rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/associations/collection_proxy.rb:46:in `delete_all'
Upvotes: 0
Views: 133
Reputation: 47472
Use following
Activity.delete_all(["company_id=? AND user_id=?", params[:id], current_user.id])
Upvotes: 1