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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:55:14+00:00 2026-05-25T06:55:14+00:00

I have a bit of ruby code: def createCal(cal) mod = @on + @off

  • 0

I have a bit of ruby code:

def createCal(cal)
    mod = @on + @off #line creating error.
    @daycount = 0       
    cal
  end

This generates the following error: NoMethodError at /calendar undefined method `+’ for nil:NilClass file: main.rb location: createCal line: 83

I am using this in Sinatra, and so I can print out @on and @off onto a webpage and I can confirm that they are in fact being loaded with values. I also do a ‘@ooo = @on + @off’ in my haml template and that produces 7, which is to be expected because on is 4 and off 3.

Any ideas?

UPDATE:

Here’s how I’m handling @on and @off

post '/calendar' do
  @on = params["on"]
  @off = params["off"]
  @date = params["date"]
  a = Doer.new
  @var = a.makeDate(@date)
  @on = @on.to_i
  @off = @off.to_i
  @ooo = @on + @off
  @cal = a.makeCal(@var)
  haml :feeling
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-05-25T06:55:14+00:00Added an answer on May 25, 2026 at 6:55 am

    You’re accessing two different instance variables:

    • The @on in post is an instance variable for your Sinatra instance.
    • The @on in createCal is an instance variable from your Doer instance.

    To use @on and @off like you want, you’ll need to change them into arguments passed to the createCal method. Something like this:

    class Doer
      def createCal(cal, on, off)
        mod = on + off
        # more code...
        cal
      end
    end
    
    post '/calendar' do
      a = Doer.new
      date = a.makeDate params['date']
      @cal = a.makeCal date, params['on'], params['off']
    
      haml :some_template
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bit of code that looks like this: text = reg.Replace(text, new
I have seen this in a lot of code written using Ruby-on-Rails. It seems
i have bit of code that causes an underflow: var t1, t2, delta: DWORD:
I have this bit of javascript written with jQuery 1.2.5. It's contained inside the
I have a bit of code that basically reads an XML document using the
I have a bit of code that passes around a ton of objects and
I have this bit of script to widen a text box on mouseover and
Does anyone have any insights regarding compiling Ruby code for Windows? I've tried both
I am a bit stuck with this. I have to interface with an api
I'm just starting out using Ruby and I've written a bit of code to

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.