开发者

how to call cosine and sine function in .html.erb file?

开发者 https://www.devze.com 2023-04-06 03:00 出处:网络
Myform calls trig functions like sin and cos, but I\'m unable 开发者_如何学编程to compile it ; it keeps returning me this error message

My form calls trig functions like sin and cos, but I'm unable 开发者_如何学编程to compile it ; it keeps returning me this error message

undefined method `cos' for #<#<Class:0x10345d6d0>:0x1034488c0>

How can I fix this error ?

I am unable to paste my code to this window, but I have "include Math" and

<% @project.UsableArea = @project.DevelopableRoofArea / (cos(@project.TiltAngle) + 3 * sin(@project.TiltAngle)) %>


You need to prefix the cos and sin methods with the module name:

Example:

<%= Math.cos(0.5) %>

In your case:

<% @project.UsableArea = @project.DevelopableRoofArea / (Math.cos(@project.TiltAngle) + 3 * Math.sin(@project.TiltAngle)) %>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号