I’m trying to use composed_of within my model. I have a field in my
database named ‘card1’, which is simply a string. I have this in my
class Player < ActiveRecord::Base
composed_of :card1, :class_name => ‘Card’
attr_reader :value, :suit
@value = s.chr
@suit = s.chr
The accessor method works fine…in my fixture I have a Player created
with card1: As, and I can do
players(:first).card1.suit # => ‘s’
But I can’t assign it:
players(:first).card = nil
NoMethodError: You have a nil object when you didn’t expect it!
The error occured while evaluating nil.card1
There is no validation for card1 in the Player class. For some reason
I simply can’t assign card1. What am I doing wrong?