I have a method defined as athlete which is founder in the user model and and a boolean column defined as athlete with the default value of false.
The provider is either twitter or facebook, if the provider is not any of those and blank then I want it to just toggle the athlete column to true in the method below.
def athlete?
provider.blank?
end
I tried multiple things but have no luck like toggle method below no luck.
def athlete?
provider.blank?
user.toggle!(:athlete)
end
Since I don’t know the column type of the Provider, I’m assuming it’s a string with possible values of “facebook”, “twitter”, and “”. Try something like this and let me know what you get
All this does is checks if the provider contains “twitter” or “facebook”, if not, then return true.
If you would like to update the attribute, then do something like this: