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?
u is a collection of Users, 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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With