问题标签 [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.

0 投票
1 回答
1588 浏览

ruby-on-rails - 我如何 `git diff` 更改 rails 5.2 凭据?

我希望能够区分对我的 encrypted 的更改config/credentials.yml.enc

git diff单独显示加密文件内容的差异。我想看看明文的变化。

如何获得config/credentials.yml.enc文件的人类可读差异?

0 投票
3 回答
164 浏览

ruby-on-rails - 无法创建新的 Rails 项目

我在运行几个命令时突然遇到了一些问题,例如rails -v or rails new project_name

我实际上已经在我的 macbook pro 上成功安装了 rails 5。但有时我试图克隆一个旧的 rails 项目并运行 bundle install ,从那时起我就面临这个问题。它说 in 'raise_if_conflicts': Unable to activate rails-3.0.1, because bundler-1.16.1 conflicts with bundler (~> 1.0.0) (Gem::ConflictError)

附上截图以获取更多信息!有人可以帮忙吗?

0 投票
2 回答
2143 浏览

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.

Image Cropping

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

0 投票
0 回答
505 浏览

javascript - 发送图像时的 Rails 5.2 ActionCable 和 ActiveStorage

我尝试按照一些 ActionCable 教程通过 ActiveStorage 创建图像记录将数据从客户端传递到服务器端,但它不起作用。

这是我的代码:来自客户端的代码确实传递到服务器端,但我无法通过 ActiveStorage 创建新图像。请帮我解决它并告诉我它为什么会发生。谢谢。

我已经将 pass 图像测试为 base64/blob(我真的不知道)

Room_channel.rb

房间.咖啡

Ps:我上面的代码没有考虑缩进。它确实在我的机器上工作。

0 投票
4 回答
1752 浏览

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!

0 投票
3 回答
15030 浏览

ruby-on-rails - 在 Rails 5.2 中分离 secret_key_base?

我刚刚从 5.1 升级到 5.2,我对这种存储秘密的“更好”方法感到很困惑......

也许我不明白,但现在开发和生产似乎已经“合并”成一个单一SECRET_KEY_BASE的以及master.key......这是正确的吗?

如果没有,我如何使用单独的主密钥并SECRET_KEY_BASE在开发中?

如果我有开发人员帮助我并且我不希望他们知道我在生产中使用的主密钥(或秘密)怎么办?

0 投票
3 回答
955 浏览

ruby-on-rails - Rails 5.2 异常未显示

我从 5.1 升级到 5.2,现在我的异常没有显示,我看到 500 错误页面,好像我config.consider_all_requests_local设置为 false ......但是它设置为true我的development.rb

此外,作为旁注,当异常发生时,在rails响应之前,终端中会出现 10 秒的日志输出。日志输出太多,我什至无法滚动查看错误是否由其他东西触发。

0 投票
1 回答
772 浏览

rails-activestorage - ActiveStorage 获取脏对象,说明图像是否已更改

我想知道 ActiveRecord 模型对象上的图像是否已更改,以便我可以执行其他功能,但看不到任何可用于了解这一点的信息。

IE

0 投票
3 回答
12143 浏览

rails-activestorage - 在 Rails 5.2 中禁用活动存储

将 Rails 升级到 5.2,我发现我必须将 storage.yml 提交到版本控制中。我不打算使用 ActiveStorage。有没有办法禁用它?

0 投票
1 回答
4148 浏览

ruby-on-rails - 显示带有表单错误的活动存储验证错误

我正在使用, rails 5.2,bootstrap-4文件上传成功。我想要的是当我在表格中输入公司名称时,它应该检查.bootstrap_formactive-storagecompany_logo

我试过了,当我在表单中包含错误循环时,它运行良好。

型号代码

我想要这种带有文件字段的验证 我想要这种带有文件字段的验证