Skip to content

Instantly share code, notes, and snippets.

@robins35
Last active January 4, 2019 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robins35/ddd8616f05bfaa256292ab1d559e0c46 to your computer and use it in GitHub Desktop.
Save robins35/ddd8616f05bfaa256292ab1d559e0c46 to your computer and use it in GitHub Desktop.
>> gu = GlobalUser.find 4205;
?> gu.receive_direct_message_alerts
=> false
>> gu.receive_direct_message_alerts = true # Below we see the expression returns false, yet the return value still shows true.
Expression result is: false
=> true
>> gu.receive_direct_message_alerts # Here we can see that the method is working as intended, the value is still set to false, however the console returns true above.
=> false
def receive_direct_message_alerts=(flag)
puts "Expression result is: #{staff.first.is_admin? && super(flag)}"
return false unless staff.first.is_admin?
staff.first.is_admin? && super(flag)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment