When not responding to gid on respond_to?(:gid) && gid because gid is actually nil.
The checking goes to user_hash[:pw_gid] = groups.where(name: user_login_id).first.gid if groups.where(name: user_login_id).count > 0 which will call query to count over and over even though the result is 0 (this is why gid is nil).
Add a query to count the number of gid in the previous step to make sure the program doesn't search the gid by telling that the gid count is actually 0.
When not responding to gid on
respond_to?(:gid) && gid
because gid is actually nil.The checking goes to
user_hash[:pw_gid] = groups.where(name: user_login_id).first.gid if groups.where(name: user_login_id).count > 0
which will call query to count over and over even though the result is 0 (this is why gid is nil).Add a query to count the number of gid in the previous step to make sure the program doesn't search the gid by telling that the gid count is actually 0.
@giosakti