前段时间我运行了以下迁移:
class CreatePipelineSpecs < ActiveRecord::Migration
def change
create_table :pipeline_specs do |t|
t.integer :id_no
t.string :od
t.string :wt
t.string :material
t.string :spec_type
t.string :spec_grade
t.string :mop
t.string :stress_level
t.string :joints
t.text :notes
t.string :ip
t.references :pipeline, index: true, foreign_key: false
t.timestamps null: false
end
add_index :pipeline_specs, :id_no
end
end
Run Code Online (Sandbox Code Playgroud)
我不知道现在发生了什么事,但我每次运行时rake db:migrate的scheme.rb文件被使用更新:
create_table "pipeline_specs", force: :cascade do |t|
t.integer "id_no"
t.string "od"
t.string "wt"
t.string "material"
t.string "spec_type"
t.string "spec_grade"
t.string "mop"
t.string "stress_level"
t.string "joints"
t.text "notes" …Run Code Online (Sandbox Code Playgroud) 我希望我的问题有道理 - 不确定最好的方式来形容这一点.我有一个分组的Select2选择表单输入如下:
所以你开始输入App,当然你可以Apples从Select2下拉菜单中获得.如果你输入veg你Vegemite和Vegetables组标题,但所有的选项都隐藏.如果搜索字词与组标题匹配,我想保持所有组选项可见.
我在select2源代码中进行了一些挖掘,我认为它实际上很容易,但我可能是错的,如果我是对的,我会被困在如何使它工作.以下是源代码: https://github.com/select2/select2/blob/81a4a68b113e0d3e0fb1d0f8b1c33ae1b48ba04f/src/js/select2/defaults.js:
我创建的Gist与尝试将其粘贴在此处:
https://gist.github.com/jasper502/40b810e55b2195476342
我切换了代码的顺序,并进行了一些轻微的变量名称更改以反映这一点.我认为这将使期权组保持开放.我试图基于此创建一个自定义匹配器(请参阅我的要点),但我被困在它调用的地方DIACRITICS:
经过一些谷歌搜索,我意识到这正在取代重音字符,我知道我没有,所以我删除了那部分.
现在我的匹配器TypeError: data.indexOf is not a function. (In 'data.indexOf(term)', 'data.indexOf' is undefined)
在我的浏览器中出错了.
我相信我在这里非常接近但是我有点超过我的经验和/或技能水平来完成这个.任何指针或想法将不胜感激.
UPDATE
这是一个与我合作的JSfiddle:
<%= f.button :button, 'Move', class: "btn btn-warning", data: { disable_with: "<i class='fa fa-spinner fa-spin'></i> Moving…"} %>
Run Code Online (Sandbox Code Playgroud)
这适用于Chrome,但在Safari中失败.这适用于链接,但不适用于按钮或提交.似乎有一些帖子,但没有明确的答案.我的网页控制台没有抛出任何JS错误等.
该按钮实际上已禁用(您可以在单击按钮后看到"请勿进入"图标悬停片刻),但文本不会更改.
我可以忍受这个,但解决它会很好.
我有一个嵌套表单,其中嵌套表单项以主表单中的选择为条件。我将表格的嵌套部分放在涡轮框架中。我有手动链接来更新框架,如下所示:
\n<a data-turbo-frame="items" href="http://localhost:3000/parent_model/new?nested_id=2">Second Nested Item</a>\nRun Code Online (Sandbox Code Playgroud)\n我想要现有的选择而不是链接,我必须在更改时动态重新加载该框架。
\n我发现了这个:https ://discuss.hotwired.dev/t/how-to-use-turbo-visit-and-target-a-specific-frame/2441它给出了如下解决方案:
\nlet frame = querySelector(\xe2\x80\x98turbo-frame#your-frame\xe2\x80\x99)\nframe.src = \xe2\x80\x98/my/new/path\xe2\x80\x99\nframe.reload()\nRun Code Online (Sandbox Code Playgroud)\n我仍在寻找一种直接优雅的单线,例如onChange...VS 看起来像完整的刺激控制器等。
我将Datatables添加到我的Rails应用程序中.我大部分时间都在工作,但我遇到了CSS/jQuery问题.我有一个行单元定义如下:
content_tag(:abbr, "#{record.od} mm", data: { container: 'body', toggle: 'tooltip', placement: 'bottom', html: 'true' }, title: 'test' )
Run Code Online (Sandbox Code Playgroud)
它呈现:
<abbr data-container="body" data-toggle="tooltip" data-placement="bottom" data-html="true" title="test">88.9 mm</abbr>
Run Code Online (Sandbox Code Playgroud)
在非数据表中,引导工具提示工作正常,但在数据表上失败.根据经验我收集它是因为数据表是在主体完成后呈现的.
经过一番挖掘后我尝试了这个:
$ ->
$('#table').dataTable
ajax:
url: myurl
processing: true
serverSide: false
responsive: true
'fnCreatedCell': (nTd, sData, oData, iRow, iCol) ->
$(nTd "abbr").tooltip()
Run Code Online (Sandbox Code Playgroud)
这几乎可以工作......几乎是因为我得到了一个工具提示,但我猜它是一个数据表工具提示与引导工具提示:
忘记工具提示内容 - 格式化等问题.非引导工具提示也需要更长时间才能淡入.
这里可能有一个简单的解决方案吗?
谢谢,
担
我有包含在涡轮框架中的内容和搜索表单。当用户在搜索字段中输入内容时,内容会实时更新。问题是搜索字段每次都会失去焦点。
有什么方法可以保持注意力集中吗?它也应该只在打字时进行,而不是与其他表单输入交互。
我可以将搜索字段移到 Turbo 框架之外,但考虑到我喜欢的 div 布局,这并不是那么理想。
更新: 我在做了一些挖掘并意识到这可能是twitter-bootstrap导致问题后更新了这个.
这是我的嵌套表单的粗略版本:
<%= simple_nested_form_for @user, :html => { :class => 'form-horizontal' } do |f| %>
<fieldset>
<%= f.input :email %>
<%= f.input :name_first %>
<%= f.input :name_last %>
<table class="table table-striped">
<thead>
<tr>
<th>Active</th>
<th>Company</th>
<th>Role</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<%= f.simple_fields_for :roles, :wrapper_tag => :tr do |role_form| %>
<td><%= role_form.hidden_field :id %><%= role_form.input :active, :label => false, :wrapper => false %></td>
<td><%= role_form.association :company, :label => false, :wrapper => false %></td>
<td><%= role_form.input :role, :label => false, :collection …Run Code Online (Sandbox Code Playgroud) 我把谷歌用Google搜索到了这个问题的相关帖子.我不认为这是一个Rails/Ruby问题,但不知道下一步该怎么做.
irb(main):007:0> Net::HTTP.get_response("http://www.apple.com","")
SocketError: getaddrinfo: nodename nor servname provided, or not known
from /Users/dan/.rbenv/versions/2.2.3/lib/ruby/2.2.0/net/http.rb:879:in `initialize'
Run Code Online (Sandbox Code Playgroud)
否则没有网络问题.apple.com在浏览器中加载正常.这是我本地计算机上开发的rails应用程序.希望通过第三方API提取JSON请求.所有Net :: HTTP请求都是这样的.
我正在显示页面上执行内联编辑功能,并使用涡轮加载的框架上方的“编辑”按钮。尝试在编辑按钮上添加一个开关,使其在编辑模式下切换到取消按钮。
我认为一个简单的刺激控制器就可以解决这个问题,除非您添加了data-action="click->edit-button#toggle"覆盖按钮上的涡轮动作的控制器。想法?有想法吗?
<div turbo-controller="edit-button">
<a class="btn btn-sm btn-primary btn-outline" data-turbo-frame="project" data-edit-button-target="button" data-value="show" href="/foobar/234/edit">Edit</a>
<turbo-frame id="project">
content
</turbo-frame>
</div>
Run Code Online (Sandbox Code Playgroud) 我有一个 Rails 模型:
has_many_attached :files
Run Code Online (Sandbox Code Playgroud)
默认情况下,通过 Active Storage 上传时,如果您上传新文件,它会删除所有现有上传内容并将其替换为新文件。
我有一个控制器破解,由于多种原因,它不太理想:
在 Rails 6 中使用 has_many_attached 更新图像的正确方法是什么
有没有办法配置 Active Storage 以保留现有的存储?
jquery ×3
turbolinks ×3
javascript ×2
datatables ×1
nested-forms ×1
ruby ×1
safari ×1
select2 ×1
simple-form ×1
stimulusjs ×1
turbo-rails ×1
ujs ×1