由于某种原因,我无法获得设计帮助方法sign_in的工作. current_user保持为null.任何想法可能是什么问题?
测试:
before :each do @user = FactoryGirl.create :user sign_in @user end describe "GET index" do it "assigns all subscribers as @subscribers" do subscriber = @user.subscribers.create! valid_attributes get :index assigns(:subscribers).should eq([subscriber]) end end
执行:
def index @subscribers = current_user.subscribers.all <------- ERROR respond_to do |format| format.html # index.html.erb format.json { render json: @subscribers } end end Error: NoMethodError: undefined method `subscribers' for nil:NilClass
任何帮助是赞赏.谢谢!