当我尝试预编译我的资产时,我收到以下错误.这是具有完整输出的跟踪:
RAILS_ENV=production bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
rake aborted!
TypeError: can't dup NilClass
/var/lib/gems/2.3.0/gems/redis-activesupport-5.0.3/lib/active_support/cache/redis_store.rb:38:in `dup'
/var/lib/gems/2.3.0/gems/redis-activesupport-5.0.3/lib/active_support/cache/redis_store.rb:38:in `map'
/var/lib/gems/2.3.0/gems/redis-activesupport-5.0.3/lib/active_support/cache/redis_store.rb:38:in `initialize'
/var/lib/gems/2.3.0/gems/activesupport-5.0.5/lib/active_support/cache.rb:60:in `new'
/var/lib/gems/2.3.0/gems/activesupport-5.0.5/lib/active_support/cache.rb:60:in `lookup_store'
/var/lib/gems/2.3.0/gems/railties-5.0.5/lib/rails/application/bootstrap.rb:64:in `block in <module:Bootstrap>'
/var/lib/gems/2.3.0/gems/railties-5.0.5/lib/rails/initializable.rb:30:in `instance_exec'
/var/lib/gems/2.3.0/gems/railties-5.0.5/lib/rails/initializable.rb:30:in `run'
/var/lib/gems/2.3.0/gems/railties-5.0.5/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
/usr/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/usr/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
/usr/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
/usr/lib/ruby/2.3.0/tsort.rb:347:in `each'
/usr/lib/ruby/2.3.0/tsort.rb:347:in `call'
/usr/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
/usr/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
/usr/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
/var/lib/gems/2.3.0/gems/railties-5.0.5/lib/rails/initializable.rb:54:in …Run Code Online (Sandbox Code Playgroud) 我试图提取方括号内的内容.到目前为止,我一直在使用它,这有效,但我想知道,而不是使用这个删除功能,如果我可以直接使用正则表达式中的东西.
a = "This is such a great day [cool awesome]"
a[/\[.*?\]/].delete('[]') #=> "cool awesome"
Run Code Online (Sandbox Code Playgroud) Rails API 文档说明了以下关于has_many_attached和has_one_attched方法的内容:
如果 :dependent 选项未设置,则每当记录被销毁时,所有附件都将被清除(即销毁)。
具体来说,我应该为这个选项指定什么值?
我有这种类型的单元测试 -
describe "#test_feature" do
it "should test this feature" do
sign_in @group_user
get :get_users, {name: "darpan"}
expect(@group_user.user_detail.name).to eq("darpan")
sign_out @group_user
end
end
Run Code Online (Sandbox Code Playgroud)
和功能get_users是这样的 -
def get_users
quick_start = current_user.user_detail.quick_start
current_user.user_detail.update_attribute(:name, "darpan")
render :json => :ok
end
Run Code Online (Sandbox Code Playgroud)
现在,当我在上面运行rspec,
current_user的user_detail被更新(有检查binding.pry),但登录用户@group_user的user_detail未更新.因此我expect失败了.
我在测试这个函数时做错了什么?