简体   繁体   English

从模型获取画布高度和宽度,并使用这些尺寸创建画布

[英]Getting canvas height and width from model and creating canvas with those dimensions

So in my mind this should be pretty simply but I cannot seem to get this right. 所以在我看来这应该很简单,但我似乎无法做到这一点。 When creating a whiteboard, the user inputs two numbers, height and width. 创建白板时,用户输入两个数字,高度和宽度。 I'm trying to apply these given numbers to the canvas object but am struggling. 我正在尝试将这些给定的数字应用于画布对象,但我正在努力。 Here's my code: 这是我的代码:

<div id=thecanvas>
    <canvas id="board" width="<%= @whiteboard.canvas_width %>" 
                       height="<%= @whiteboard.canvas_height %>">
    </canvas>
</div>

Rails expects <%= %> tags for Ruby code in a template file. Rails期望模板文件中的Ruby代码具有<%= %>标记。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM