我有一个具有枚举作为属性的模型。
class ApplicationLetter < ActiveRecord::Base
belongs_to :user
belongs_to :event
validates :user, :event, presence: true
enum status: {accepted: 1, rejected: 0, pending: 2}
end
Run Code Online (Sandbox Code Playgroud)
以及生成此模型并为枚举设置值的工厂
FactoryGirl.define do
factory :application_letter do
motivation "motivation"
user
event
status :accepted
end
end
Run Code Online (Sandbox Code Playgroud)
在控制器测试中,我想通过工厂获得有效的属性
let(:valid_attributes) { FactoryGirl.build(:application_letter).attributes }
Run Code Online (Sandbox Code Playgroud)
并创建具有这些属性的应用程序。
application = ApplicationLetter.create! valid_attributes
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
ArgumentError: '1' 不是有效状态
为什么状态被解释为字符串?如果我在工厂中更改状态,我会收到相同的错误,但使用正确的相应编号。
我目前正在使用 WebStorm 和 Airbnb 的 ESLint 配置。
有没有办法以“更柔和”的方式标记 ESLint 中的错误,而不是这种“激进”的红色,或者将 ESLint 中的所有规则标记为警告,而不用.eslintrc
“警告”列出文件中的每个规则?
javascript intellij-idea webstorm eslint eslint-config-airbnb