Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 投票制中的模型问题_Ruby On Rails_Ruby On Rails 3 - Fatal编程技术网

Ruby on rails 投票制中的模型问题

Ruby on rails 投票制中的模型问题,ruby-on-rails,ruby-on-rails-3,Ruby On Rails,Ruby On Rails 3,我有三种模式投票,选择和数字。我建立了一个索引来输入投票信息,比如标题和描述。如何使用单选按钮在数字模型中存储投票数 我的模型具有以下属性: Vote: name, description Option: vote_id, content Number: option_id, content (integer) 这是我的edit.html 我想在这个html中添加投票数函数,但我不知道如何添加。那么你能给我一些想法来完成它吗?^ u^。我是rails的新手,非常感谢您的帮助 <p id=

我有三种模式投票,选择和数字。我建立了一个索引来输入投票信息,比如标题和描述。如何使用单选按钮在数字模型中存储投票数

我的模型具有以下属性:

Vote: name, description
Option: vote_id, content
Number: option_id, content (integer)
这是我的edit.html 我想在这个html中添加投票数函数,但我不知道如何添加。那么你能给我一些想法来完成它吗?^ u^。我是rails的新手,非常感谢您的帮助

<p id="notice"><%= notice %></p>

<p>
  <b>Name:</b>
  <%= @vote.name %>
</p>

<p>
  <b>Description:</b>
  <%= @vote.description %>
</p>

    <%  for option in @vote.options %>


    <%=h option.content %><br />


<%  end %>



<%= link_to 'Back', votes_path %>

这可能会为您指明正确的方向:

您需要在输入表单中使用*fields\u for*,并将第二个模型传递给它。
如果您的模型关联关系属于、是否已正确设置了多个等,Rails应该注意后端的魔力

我不太明白。使用字段_应在子表中创建子行。您可能希望使用AJAX向服务器发送数据。您是否有任何代码可在此处发布,或者可能是github(如果太多)?^-^我已发布,请提供一些建议^-^我已发布,请提供一些建议