I'm running into a seemingly simple problem, but I can't figure out what the problem is. I'm building an API using Rails 4.
I have a model called Constant
class Constant < ActiveRecord::Base
def self.calcuate_something(a, b, c, d, e)
self.number_one + self.number_two + (self.number_three*a) + (self.number_four*b) + (self.number_five*c) + (self.number_six*d) + (self.number_seven*e)
end
end
This model has attributes number_one, number_two, number_three, number_four, number_five, number_six, and number_seven.
In my controller, I'm doing this:
@constant = Constant.find_by_id(params[:id])
number = @constant.calculate_something(1, 2, 3, 4, 5)
And then I get an error that says NoMethodError (undefined method 'number_one' for #<Class:0x007fd3d4466068>):. I'm not trying to access a method called number_one, I'm trying to find the field in the model.
I've verified that there is a column called number_one for all of my entries and that every single entry has a value. Is there something wrong with my syntax or setup??
Thanks in advance!