Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8332027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:35:57+00:00 2026-06-09T02:35:57+00:00

I have a method defined as athlete which is founder in the user model

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T02:35:59+00:00Added an answer on June 9, 2026 at 2:35 am

    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

    def athlete?
      !provider.any? { |p| %w(facebook twitter).include?(p) }
    end
    

    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:

    def athlete=(athlete)
      self[:athlete] = !provider.nil? && !provider.any? { |p| %w(facebook twitter).include?(p) } rescue true
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in my self-defined module I have this method which will query the db and
I have a c source file in which one of the method is defined
If you have a C pointer which was defined in a method and are
I have defined a method called ccy which takes in a number num ,
i have a service method addAgent defined as @Override @Transactional(readOnly=false) public void addAgent(Agent agent,
I have defined [AfterScenario] binding in my stepdefinition class and have method which will
I have GetURL method defined to find my location from network provider, you can
Possible Duplicate: Remove element of a regular array I have a method defined which
I have a custom method defined in my mongoosejs ODM schema which allows me
I have a method defined in IDL as follows : interface IMyFunc : IDispatch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.