I'm new to Ruby and obviously RoR. I used a scaffold to create a rails project. For the model I required two fields, num1:integer and num2:integer. The view that was made to create those two fields was
<%= form_for(@calculation) do |f| %>
.
.
.
<div class="field">
<%= f.label :num1 %><br>
<%= f.number_field :num1 %>
</div>
<div class="field">
<%= f.label :num2 %><br>
<%= f.number_field :num2 %>
</div>
I've been all over the internet and cannot find how to get the values that are entered into those fields in order to manipulate them. Here is what I have
<div class="actions">
<%= f.button('Add', &Calculation.add(:num1,:num2)) %>
</div>
In the above code I am trying to create a button that will run the Calculation.add method with the values from the number_fields as the numbers to add. With what I have I keep getting an error: "undefined method `+' for :num1:Symbol". I'm thinking that the num1 and num2 are just the names of the number_fields and so I need to know how to get the integers that are entered into those fields. Thanks for your help. Oh, and I'm using Ruby 193 and Rails 4.0 with the RubyMine IDE.
EDIT
Here is the model code. I'm sure its ugly for a real rubyist to see:
class Calculation < ActiveRecord::Base
def self.add (x,y)
x+y
end
def self.subtract(x,y)
x-y
end
def self.multiply(x,y)
x*y
end
end