Destroy_all with out id

I have three module named user,role and role_user. Users and roles table
has many to many relationship. And role user in the associated table or
linked another two table .It contains the user_id and role_id
.Association are established follwing this code
In user model

has_many :role_users
has_many :roles, :through => :role_users

In role model
has_many :role_users
has_many :users, :through => :role_users

In role role_user model
belongs_to :user
belongs_to :role

Is it possible to destroy the user from users table as well as delete
the corresponding user from role_users table.through destroy_all method.
I have written the code
def delete_user
@user = User.find(params[:id])
@user_id =


RoleUser.destroy_all(["user_id = ?" ,@user_id])


But it does not work please help

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs