I want to create a calculated field that multiply column1 and column2 on rails 3.
Like this :
totalpoint = column1 * column2
Where is I have to place the code? in the model? How do I write it?
How do I call it from my view?
In your controller create put the calculation in a instance variable (starts with @) in the action that is being called, eg index:
def index
@totalpoint = column1 * column2
end
In your view (index.html.erb) you can use the instance variable:
<div>
Total point = <%= @totalpoint %>
</div>
If you need to do this for multiple rows, you can use an array and use it in your view.