【问题标题】:I have a timecodes list how to update my records with those timecodes using update_attributes我有一个时间码列表,如何使用 update_attributes 用这些时间码更新我的记录
【发布时间】:2018-10-09 22:15:39
【问题描述】:

瞧,我的数据库字段中有一个类似 0、1000、2860、3619、4789、5970 的列表。我想迭代它并用时间码的值更新相应的字幕。

这是我的代码。一切尽在眼前:

          <%if params[:envoi]%>

            <%@ze_videos.each do |attached| %>
                <h1><%= attached.remarque %></h1>
                <% @mesattachedtcs = attached.remarque %>
            <%end%>
            <p> 

                <% @tchash = "" %>
                <% @mesattachedtcs.split(/, ?/).each do |montc| %>
                        <% @tchash = @tchash + '"' + montc.to_s + '"' + ', ' %> 
                <%end%>
                <%# @tchash = '{' + @tchash + '}' %>

                <%= @tchash %>
                <% aa = 0 %>
                <% @traductions.each do |sync| %>
                    <% aa += 1 %>
                    <%= @tchash[aa] %> _
                    <%  
                        @temps = (@tchash[aa]).to_i          
                        if sync.auteur == current_user.email 
                            sync.update_attributes(:timecode => @temps)
                        end
                    %>

                <%end%>
            </p>



        <%end%>

我不明白的是, 不是一个带有相应字幕的被保存。但是该值以“加密”方式进入数据库。 赞这个

我不是哈希专业人士,如果我在代码中编写哈希,它工作得很好: myhash = [111, 222, 333, 444] 并使用 myHash1, myHash 访问值或键2..

在这张图片中,您看到我没有一个完整的变量,但字符串的每个字符都在时间码列中调度,而不是在一行中。 你能帮我解决这个问题吗?谢谢

【问题讨论】:

    标签: ruby-on-rails-4 hash update-attributes


    【解决方案1】:

    对不起,我只是没有看理论。我必须先说 Hash.new()。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-09-12
      • 2021-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-06
      • 1970-01-01
      相关资源
      最近更新 更多