15得票1回答
应用程序资源文件application.css未被声明,但已在清单中声明。

我遇到了这个错误:ActionView::Template::Error (Asset `application.css` was not declared to be precompiled in production. Declare links to your assets in `ap...

19得票6回答
如何在RSpec中正确测试ActiveJob的retry_on方法?

最近几天我一直在尝试测试这种方法,但没有成功。 另外一个我想做的事情是,在进行了最后一次重试后,rescue错误信息。 请查看我的评论和代码片段,这里也有retry_on的源代码以供参考。 以下是示例代码和测试: my_job.rb retry_on Exception, w...

22得票3回答
在Rails 5中,将form_with的本地化设置为默认值为true

我正在开发一个项目,我们不会使用ajax调用来提交表单,因此我需要在项目中的每个表单中添加local: true,如Rails 文档所示: :local - 默认情况下,表单提交是远程和无障碍的XHR。 使用local:true禁用远程提交。 有没有办法默认将本地选项设置为true? 我...

13得票2回答
Rails - 通过Active Storage上传文件后在视图中显示图片

我有一个项目使用的是Rails 5.1.2,我正在尝试在其中实现Active Storage。按照几个在线教程的步骤设置了Active Storage后,我可以看到数据保存在active_storage_blobs和active_storage_attachments表中。 教程1 教程2...

9得票4回答
使用Capistrano部署Rails 5.1/Webpacker应用程序

我可以翻译以下内容: 我有一个Ubuntu服务器来部署我的Rails项目。在我的Ubuntu服务器上,我安装了RVM。 现在我想要使用Rails 5.1和Webpacker来部署新项目。为了部署这些项目,我在我的Ubuntu服务器上安装了NVM、npm和yarn。 在我的Rails 5....

39得票8回答
资产“logo.png”不在资产管道中。

在Rails 5.1.3中,我更改了app/assets/images中的标志文件,然后出现错误,不知道该如何修复。有人知道吗? The asset "logo.png" is not present in the asset pipeline. 我已经尝试了重新启动 Rails、Rail...

15得票1回答
Rails迁移(migration),引用`unique: true`未在模式中生成`unique: true`,导致constancy_fail检查失败。

我有以下的迁移 class CreateBooking < ActiveRecord::Migration[5.1] def change create_table :bookings do |t| t.integer :day_period, default:...

7得票2回答
如何在Ruby on Rails中修复"undefined method 'alias_method_chain'"错误?

我刚刚克隆了一个Github库https://github.com/maxitron93/p2pcollective.com,在探索这个很棒的P2P借贷应用程序时,我遇到了一个错误。 NoMethodError: ActiveRecord::ConnectionAdapters::Post...

40得票3回答
未定义方法 `before_filter'。

尽管该方法在下一行中明确定义,但我仍然遇到了以下错误。 undefined method `before_filter' for AuthorsController:Class 我正在按照教程进行操作。 代码片段如下: authors_controller.rb class Aut...

9得票2回答
Rspec请求规范和Rails 5

我正在开始一个新项目,这是我第一次使用Rails 5.1.0。我在我的第一个请求规范中遇到了问题。 describe 'Users', type: :request do it 'are created from external data' do json_string = F...