0

我的模型架构:

用户

has_many :activities
has_many :companies through: :activities

公司

has_many :activities
has_many :users, through: :activities

活动

belongs_to :user
belongs_to :company

当我尝试运行时出现问题,或者current_user.activities.delete_all(["company_id=?", params[:id]])我收到此错误:cleardestroy

ArgumentError: wrong number of arguments (1 for 0)
    from /home/rom/.rvm/gems/ruby-1.9.3-p194@rails-3.2.8/gems/activerecord-3.2.8/lib/active_record/associations/collection_association.rb:156:in `delete_all'
    from /home/rom/.rvm/gems/ruby-1.9.3-p194@rails-3.2.8/gems/activerecord-3.2.8/lib/active_record/associations/collection_proxy.rb:46:in `delete_all'
4

1 回答 1

1

使用以下

Activity.delete_all(["company_id=? AND user_id=?", params[:id], current_user.id])
于 2012-09-10T05:57:44.693 回答