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

  • SEARCH
  • Home
  • 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 6919107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:56:48+00:00 2026-05-27T09:56:48+00:00

How do I set a boolean to false in a method? For my BusinessStore

  • 0

How do I set a boolean to false in a method?

For my BusinessStore search I am trying to make 3 different radio buttons to choose from for Online Stores, Offline Stores and All Stores.

This my BusinessStore model and the 3 methods I am trying to make for the radio buttons:

attr_accessible :online_store # boolean attribute

def online_search
   business_store.online_store = true
end

def offline_search
   business_store.online_store = false
end

def all_search
   # Give all results whether true or false
end

How do I finish this and what needs to be corrected?


UPDATE

Product.rb

def search_type=(boolean)
   case (boolean)
    when 'online'
      @online_search = true
      @offline_search = false
    when 'offline'
      @online_search = false
      @offline_search = true
    when 'all'
      @online_search = true
      @offline_search = true
    else
    @online_search = true
    @offline_search = true
   end
end

search/index.html.erb

<%= label_tag :search_type, "All" %>
   <%= radio_button_tag :search_type, "all" %>
<%= label_tag :search_type, "Online" %>
    <%= radio_button_tag :search_type, "online" %>
<%= label_tag :search_type, "Offline" %>
    <%= radio_button_tag :search_type, "offline" %>
  • 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-05-27T09:56:49+00:00Added an answer on May 27, 2026 at 9:56 am

    Took a different approach instead and just made two checkboxes:

    SearchController.rb

    def index
      @search = Product.search do
       q.with(:online_search, params[:online_search] == 1) if params[:online_search].nil?
       q.with(:offline_search, params[:offline_search] == 0) if params[:offline_search].nil?
      end
      @products = @search.results
    end
    

    search/index.html.erb

      <%= label_tag :online_search, 'Online' %>
        <%= check_box_tag :online_search, params[:online_search], true %>
      <%= label_tag :offline_search, 'Offline' %>
        <%= check_box_tag :offline_search, params[:offline_search], true %>
    

    I set the checkboxes to start out as already checked for both in order to search online and offline unless one of them is unchecked. This is why in the search controller I search for the params being nil or not for both methods.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use the Except method on a LINQ result set using
here i make one program in this i set the time in requestlocationsupdates method
I have a boolean which is set to false when being declared, public bool
I basically want a method I can call that will set a boolean to
I have a set of five boolean values. If more than one of these
I have a vector of booleans. I need to set its elements from n-th
I'm trying to set up a site which allows users to create their own
I have tens of conditions to check that set boolean values for seven or
i am trying to set the color of row of a Swing Jtable. i
I am trying to write a little method in java, but I cannot figure

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.