调用.reload后的Nil对象

时间:2013-02-07 02:13:42

标签: ruby-on-rails

我是ruby的新手,我正在尝试解决为什么background_imagekeyline_image都会成为nill。

context 'removing background_image but not keyline_image' do
    before do
      put :update, id: business_group.id,
          business_group: { title: 'new_title',
              background_image: File.new('spec/support/files/test_photo.jpg'),
              keyline_image:  File.new('spec/support/files/test_photo.jpg') },
          remove_background_image: 1,
          remove_keyline_image: nil

      business_group.reload
      binding.pry
    end
    it { business_group.title.should == "new_title"}
    it { business_group.background_image.should_not be_nil }
    it { business_group.keyline_image.should_not be_nil}
  end

我已经完成了binding.pry并获得了以下输出:

BusinessGroup.find(business_group.id).background_image
     => <Dragonfly Attachment uid="2013/02/07/12_58_16_754_file", app=:images>

business_group.background_image
     => nil

评论赞赏

0 个答案:

没有答案