【发布时间】:2014-05-13 17:00:27
【问题描述】:
我正在学习 Treehouse 课程,但在那里的论坛上没有得到积极的回应。这是我遇到的问题:
1) Failure:
UserFriendshipTest#test_: UserFriendship should belong to friend. [/Users/Sam/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:344]:
Expected UserFriendship to have a belongs_to association called friend (Friend does not exist)
我的“user_friendship_test.rb”文件如下所示:
require 'test_helper'
class UserFriendshipTest < ActiveSupport::TestCase
should belong_to(:user)
should belong_to(:friend)
end
我的“user_friendship.rb”文件如下所示:
class UserFriendship < ActiveRecord::Base
belongs_to :user
belongs_to :friend
end
我应该指出我正在使用 Rails 4。
任何帮助将不胜感激:)
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-4 shoulda