Reputation: 9621
I'm not sure why I am getting this error:
wrong number of arguments (0 for 1)
app/models/user.rb:38:in `sign_out_by_guid'
app/helpers/user_helper.rb:11:in `sign_out'
app/controllers/users_controller.rb:18:in `destroy'
My code:
def self.sign_out_by_guid(guid)
puts 'currently in sign_out_by_guid' + guid
u = User.where("guid = ?", guid)
puts u.inspect
puts 'before destroy'
u.destroy
puts 'called destroy'
end
I can see all the puts output expect for the last one "called destroy"
So this means for sure the call to u.destroy
is the issue.
If I try getting a record in rails console
, and calling destroy on the user it works fine.
What could this be?
Upvotes: 2
Views: 2153
Reputation: 4625
check user.rb. make sure your params is
dependent: :destroy
not
dependent: destroy
Upvotes: 0
Reputation: 96994
u
is a collection of User
s, but destroy
needs to be called on a single user, or on a relation with an argument denoting the ID of the User
. You can either do:
u = User.where("guid = ?", guid).first
or
u = User.find_by_guid(guid)
Upvotes: 13