Hi everyone,
I have the following classes:
class User < ActiveRecord::Base devise :database_authenticatable, :registerable, :timeoutable, :recoverable, :rememberable, :trackable, :validatable
has_many :comments, :dependent => destroy ... end
class Comment < ActiveRecord::Base belongs_to :user belongs_to :commentable, :polymorphic => true ... end
In rails console, I can successfully create a new comment via user:
@attr = { :title => "Something", :content => "Something else" } @user.comments.create!(@attr) # this command runs successfully
However, when I try to do the same thing in RSpec, I get the following error:
Failure/Error: @user.comments.create!(@attr) NoMethodError: undefined method `comments' for #<User:0x00000004867000>
Has anyone seen this before? Could it have anything to do with the combination of RSpec and Devise?
Thanks in advance,
Mike
I'm using Rails 3.1.0, Ruby 1.9.2p290, and RSpec 2.6.4.