我遇到了ElasticSearch和Rails的问题,由于attr_protected,一些数据没有正确编入索引.Elastic Search在哪里存储索引数据?检查实际索引数据是否错误将很有用.
检查映射Tire.index('models').mapping没有帮助,列出该字段.
FactoryGirl不会设置我的受保护属性user.confirmed.这里的最佳做法是什么?
Factory.define :user do |f|
f.name "Tim" # attr_accessible -- this works
f.confirmed true # attr_protected -- doesn't work
end
Run Code Online (Sandbox Code Playgroud)
我可以@user.confirmed = true在使用我的工厂之后做一个,但是在很多测试中都有很多重复.
ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1 attr-protected factory-bot
我的用户模型中有以下代码:
attr_protected :email
Run Code Online (Sandbox Code Playgroud)
我正在尝试创建一个新的用户对象,但我使用以下代码获得了一个质量分配保护错误.
user = User.new(
:first_name => signup.first_name,
:last_name => signup.last_name,
:email => signup.email,
:birthday => signup.birthday,
:encrypted_password => signup.encrypted_password,
:salt => signup.salt
)
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决attr_protected以使此代码工作并为电子邮件分配值?
谢谢.
factory-bot ×1