问题标签 [ruby-on-rails-5.2]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
ruby-on-rails - 我如何 `git diff` 更改 rails 5.2 凭据?
我希望能够区分对我的 encrypted 的更改config/credentials.yml.enc
。
git diff
单独显示加密文件内容的差异。我想看看明文的变化。
如何获得config/credentials.yml.enc
文件的人类可读差异?
ruby-on-rails - How to create a cropped and centered image with Imagemagick's command line options with variant?
I have a Ruby on Rails 5.2 RC2 app that uses ActiveStorage for hosting images. In particular it's transforming images with variant.
I would like to pass an image, typically of 16:9 or 4:3 ratio and have variant
crop it to a specific ratio, width x height, and have it centered. The image could be horizontal or vertical, but the new cropped size is centered.
From the Imagemagick Command Line Options documentation, I have the following:
<%= image_tag @photo.image.variant(extent: "1:1", crop: "800x800").processed.service_url %>
It creates a square crop, but it's not centered. It defaults to the left. How do I create a cropped image that's centered with Imagemagick's command line option?
I'm looking for a solution that should work on any image size or aspect ratio. I believe any resizing works off of the originally uploaded image for creation.
For reference, I'm looking to upgrade an older Rails app that uses Carrierwave. There is a resize_to_fill
that does exactly that. Example code:
version :square_thumb do
process :resize_to_fill => [200,200]
end
javascript - 发送图像时的 Rails 5.2 ActionCable 和 ActiveStorage
我尝试按照一些 ActionCable 教程通过 ActiveStorage 创建图像记录将数据从客户端传递到服务器端,但它不起作用。
这是我的代码:来自客户端的代码确实传递到服务器端,但我无法通过 ActiveStorage 创建新图像。请帮我解决它并告诉我它为什么会发生。谢谢。
我已经将 pass 图像测试为 base64/blob(我真的不知道)
Room_channel.rb
房间.咖啡
Ps:我上面的代码没有考虑缩进。它确实在我的机器上工作。
ruby-on-rails - How to test emails that are set to deliver later
I can't figure out how to get the syntax to work for asserting that an email has been enqueued properly. Specifically, how do you pass in the arguments to the mailer when the argument is an object?
For example, if you want to pass in a contact object to the example from the documentation:
None of these appear to work. If you look at the actual enqueued job, the object looks like this:
Any help is appreciated!
ruby-on-rails - 在 Rails 5.2 中分离 secret_key_base?
我刚刚从 5.1 升级到 5.2,我对这种存储秘密的“更好”方法感到很困惑......
也许我不明白,但现在开发和生产似乎已经“合并”成一个单一SECRET_KEY_BASE
的以及master.key
......这是正确的吗?
如果没有,我如何使用单独的主密钥并SECRET_KEY_BASE
在开发中?
如果我有开发人员帮助我并且我不希望他们知道我在生产中使用的主密钥(或秘密)怎么办?
ruby-on-rails - Rails 5.2 异常未显示
我从 5.1 升级到 5.2,现在我的异常没有显示,我看到 500 错误页面,好像我config.consider_all_requests_local
设置为 false ......但是它设置为true
我的development.rb
。
此外,作为旁注,当异常发生时,在rails响应之前,终端中会出现 10 秒的日志输出。日志输出太多,我什至无法滚动查看错误是否由其他东西触发。
rails-activestorage - ActiveStorage 获取脏对象,说明图像是否已更改
我想知道 ActiveRecord 模型对象上的图像是否已更改,以便我可以执行其他功能,但看不到任何可用于了解这一点的信息。
IE
rails-activestorage - 在 Rails 5.2 中禁用活动存储
将 Rails 升级到 5.2,我发现我必须将 storage.yml 提交到版本控制中。我不打算使用 ActiveStorage。有没有办法禁用它?