I have two Rails 4 models: Journey and Place. I would like a Journey two have two fields, origin and destination, that are both Places. My Journey class looks like this:
class Journey < ActiveRecord::Base
has_one :origin, class_name: :place
has_one :destination, class_name: :place
end
Firstly, do I also need something in my Place class? I thought I would need two "has_many" declarations, but I couldn't work out the syntax given the two references.
Secondly, would it be possible to reference the origin Place of a Journey using syntax like "j.Origin", where "j" is a Journey record? (And similarly for the destination.)