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 631757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:00:06+00:00 2026-05-13T20:00:06+00:00

I need to write a method that returns whether or not a Boolean is

  • 0

I need to write a method that returns whether or not a Boolean is set to true/false.

In my case the boolean is an attribute for a product. And to skip a step in the checkout process I need to have this self method work similar to the following:

def current_user
  return @current_user if defined?(@current_user)
  @current_user = current_user_session && current_user_session.user
end

this example is from the application_controller, and is doing the same thing in the checkout process that I need to do here.

The use for this once I have it working is:

def checkout_steps                                                      
  checkout_steps = %w{registration billing shipping shipping_method payment confirmation}
  checkout_steps.delete "registration" if current_user
  checkout_steps
end

I need a boolean that works the same as the delete item above. I am trying to learn how this works so any explanation is greatly appreciated to.

thoughts?

  • 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-13T20:00:07+00:00Added an answer on May 13, 2026 at 8:00 pm

    I’m not quite sure I follow your question, but if you’re asking how this line works:

    checkout_steps.delete "registration" if current_user
    

    It’s not the way current_user returns its value that’s doing it. It’s a built-in syntax of Ruby where you can specify one line if statements in the following form:

    <statment> if <condition> # only execute <statement> if <condition> is true
    

    instead of the more traditional way:

    if <condition> then
      <statement>
    end
    

    As will the full if/end syntax, Ruby will only evaluate the statement if the condition is true, and the condition can be any code you might normally place in an if condition.

    In your case, if the product’s attribute is something like can_be_shipped, indicating whether the item can be shipped you can simply do

    checkout_steps.delete 'shipping' if !@product.can_be_shipped
    

    Rails supports another syntax for testing whether the condition evaluates to false:

    <statment> unless <condition> # only execute <statement> if <condition> is false
    

    Which could be used to make the logic clearer:

    checkout_steps.delete 'shipping' unless @product.can_be_shipped
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 506k
  • Answers 506k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You've misunderstood. The hook overview in MSDN describes it like… May 16, 2026 at 3:39 pm
  • Editorial Team
    Editorial Team added an answer TextSwitcher is exactly what you are looking for. Just use… May 16, 2026 at 3:39 pm
  • Editorial Team
    Editorial Team added an answer Check out jQuery and jQuery UI Dialogs. Of particular interest… May 16, 2026 at 3:39 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I need to create a unit test for a method that returns an xmldocument.
I want to write a decorator that acts differently depending on whether it is
I had a need for a method that could take a collection of strings,
If I am using ReaderWriterLockSlim to acquire read/write locks, do I need to make
I have a type and an interface and I need to verify that the
I'm writing a log collection / analysis application in Python and I need to
I have a class WebServiceCaller that uses NSURLConnection to make asynchronous calls to a
I've got a class with some functions which realistically are just 'helper' methods that
Im learning Spring (2 and 3) and i got this method in a ClientDao
So I've read that ActualWidth may equal 0 until it is fully loaded. I

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.