小编cod*_*ear的帖子

Rails 4在一个表单中创建相同模型的多个记录

我试图一次为同一个模型创建多个记录(Rails 4.1.2),但表单只发送一组参数值(实际上只是第一行)...

基本上我在索引视图中有一个表单,只需单击+符号(使用javascript附加表行)添加更多记录,一次添加更多行记录...并点击提交一次创建所有记录.

以下是我到目前为止的观点:

 <div class="table-responsive">
   <table class="table equipment-table" id="EquipmentTable">
     <thead>
       <tr>
         <th>Equipment name</th>
         <th>Serial number</th>
         <th>Date out warehouse</th>
         <th>Date in warehouse</th>
         <th>Technician</th>
         <th>Site location</th>
         <th>Date in</th>
         <th>Date out</th>
         <th>Technician return</th>
       </tr>
     </thead>

     <tbody id="tableToModify">
       <% @equipments.each do |equipment| %>
       <tr>
         <td><%= equipment.equipment_name %></td>
         <td><%= equipment.serial_number %></td>
         <td><%= equipment.date_out_warehouse %></td>
         <td><%= equipment.date_in_warehouse %></td>
         <td><%= equipment.technician %></td>
         <td><%= equipment.site_location %></td>
         <td><%= equipment.date_in %></td>
         <td><%= equipment.date_out %></td>
         <td><%= equipment.technician_return %></td>
       </tr>
       <% end %>

       <%= form_tag make_multiple_equipments_path, method: :post do %>

          <tr …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails ruby-on-rails-4

6
推荐指数
1
解决办法
3928
查看次数

获取辅助函数内的流星方法返回值

我在server /functions.js文件中有以下内容:

Meteor.methods({
    checkIfVoted: function (postId) {
        if (postId) {
            ...
            if (condition is met) {
                return true;
            } else {
                return false;
            }
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

然后在客户端 /showPost.js中的以下内容:

Template.showPost.helpers({
    alreadyVotedByUser: function () {
        var answer = false;
        if(this) {
            Meteor.call("checkIfVoted", this._id, function(err, response) {
                if (response) { console.log(response); }
                answer = response;
            });
        }
        console.log(answer);
        return answer;
    }
});
Run Code Online (Sandbox Code Playgroud)

当我在执行console.log响应时,我在条件满足时得到值为true,但是answer变量不接受它,并且仍然显示为其值为false.

(我知道我将Meteor方法放在服务器目录中而不是在公共目录中,以便在客户端和服务器之间共享以提供延迟补偿)

如果有人可以帮助我,我们将非常感谢.

meteor

3
推荐指数
1
解决办法
2893
查看次数

流星 - 如何隐藏使用的流星版本

我想问一下,出于安全原因 - 我们应该能够从页面源部分和其他无头浏览器/ curl请求中删除meteor_runtime_config部分中的流星版本信息,如下所示:

__meteor_runtime_config__ = {"meteorRelease":"METEOR@1.0.3.1"...
Run Code Online (Sandbox Code Playgroud)

特别是以便不利用已知的漏洞.这为开发人员提供了一些时间来捕获新版本,特别是对代码的更改.

在2014年的博客文章中,据报道有31个应用程序删除了版本号,因此可以这样做.

javascript meteor

3
推荐指数
1
解决办法
100
查看次数