我需要ActiveStorage中的新函数resize_to_fill,因此我升级到了Ruby 2.5.1和Rails 6。
ruby '2.5.1'
gem "rails", github: "rails/rails"
Run Code Online (Sandbox Code Playgroud)
当我停止然后启动服务器(Cloud 9)时,我收到了Rails错误:
阻止的主机:xxxxxxx-xxxxxxx.c9users.io要允许对xxxxxxx-xxxxxxx.c9users.io的请求,请添加以下配置:
Rails.application.config.hosts <<“ xxxxxxx-xxxxxxx.c9users.io”
我尝试过重新启动,新窗口,但是没有任何东西可以解决。我以前从未见过此错误。我猜新版本的Rails正在做什么?
我正在尝试使用Active Storage管理图像。我可以进行多个上传,但是我想使用可排序jQuery的acts_as_list位置来使用ajax来管理其顺序,如本网站的视频中所示。在普通模型中,我将运行迁移以向模型添加位置。但似乎我无法访问Blob或Attachment模型。我该如何解决?还是我必须重新使用Carrierwave?任何帮助,将不胜感激。
为了澄清起见,让我添加代码。
show.html.erb
<p id="notice"><%= notice %></p>
<p>
<strong>Title:</strong>
<%= @post.title %>
</p>
<p>
<strong>Content:</strong>
<%= @post.content %>
</p>
<% if @post.images.attached? %>
<p>
<strong>Images:</strong>
<br>
<div id="images" class="list-group" data-url="<%= sort_posts_path %>">
<% @post.images.order(:position).each do |image| %>
<%= link_to image_tag image.variant(resize: "200x200"), class: "list-group-item", id: dom_id(image) %>
<% end %>
</div>
</p>
<% end %>
<%= link_to 'Edit', edit_post_path(@post) %> |
<%= link_to 'Back', posts_path %>
Run Code Online (Sandbox Code Playgroud)
posts.js
document.addEventListener("turbolinks:load", function() {
$("#images").sortable({
update: function(e, ui) {
/* Update …Run Code Online (Sandbox Code Playgroud)