English 中文(简体)
用于真正铁路的未界定方法
原标题:undefined method id for TrueClass Rails
  def can_save(board,role)
    if ar_user = already_registered?(email) || user = self.save
      Participant.make(ar_user||user, board, role)
    end
    user
  end

I do this rspec test on it:

it "should return the user if the user is not already registered" do
     lambda do
      user = @new_user.can_save(@board, "Manager")
    end.should change(User,:count).by(1)
   end

我发现这一错误:

  undefined method `id  for true:TrueClass

为什么如此?

最佳回答

<代码>save 方法回归真实或虚假,而不是保存的物体。

问题回答

暂无回答




相关问题
How to use rspec to test named routes?

Given I have a named route: map.some_route /some_routes/:id , :controller => some , :action => other How do I use the routing spec file spec/routing/some_routing_spec.rb to test for that ...

Silencing Factory Girl logging

Just to clear the air, I am not some cruel factory master trying to silence working ladies. I am having a very annoying problem where when using Thoughtbot s factory girl in my specs, every time ...

Controller specs in isolation mode and render :update

I am using RSpec for writing my controller tests/specs. I faced the problem, that the following code gets rendered: render :update do |page| page[ middle_content ].replace_html :partial => "...

rspec testing views with internationalization?

I want to make sure I have the right meta desc/keyword and title text in my view so I want to create rspec views tests for that. Now the real challange here is how to make it work across multiple ...

热门标签