To preface this, I am new to ruby and rails but I have done my homework and I really thought I was doing this right. So in my rails controller, I am loading another class called Input. I want to create an instance of the Input class and then call calc_value.
foo = Input.new "foo", 10, 120
render json: foo.calc_value
I know that all of the loading is setup correctly and I know that i can initialize foo correctly (I tried rendering the variable by itself without calling calc_value). But when I call calc_value I receive a "undefined method 'calc_value' for #".
Here is my Input class:
class Input
def initialize (n = "", v = 0, m = 0)
@name = n
@value = v
@maxValue = m
end
def calc_value
@value
end
end
I thought this would be simple and I have read everything over and over again about class variables and methods vs instance variables and methods. I am at my wits end here.