I have a User model and a Message model. My message table has the columns created_for, and created_by and these are both foreign keys to the User table.
I'm currently getting this error message:
undefined methodcreated_for_id' for #`
How can I get this to work without having to change my columns to created_for_id and created_by_id?
class User < ActiveRecord::Base
has_one :message
end
class Message < ActiveRecord::Base
#belongs_to :user
belongs_to :created_by, :class_name => "User" # Basically tell rails that created_by is a FK to the users table
belongs_to :created_for, :class_name => "User" # Basically tell rails that created_for is a FK to the users table
attr_accessible :created_by, :created_for, :message
end