Q:

Access ID of parent model from associated model in rails

ok, I have the following models in rails:

'Shards' 
'Realities' which either belong to a shard, or which belong to nothing
'Spaces' which belong to a reality
'Properties' which belong to spaces

I can access shard.reality.space.first.properties, but I'd like to be able to access the 'shard' id from a custom method in the property model if it has been accessed in this way. 
Is there any way of doing this?

A:

class Property < ActiveRecord::Base
  belongs_to :space

  def custom_method
    space.reality.shard.id if space.reality.shard
  end
end

