For some reason my model does not contain the associated models I linked using has n.
My definition is as follows:
class Post
include DataMapper::Resource
has n, :comments
property :id, Serial
property :name, String
end
class Comment
include DataMapper::Resource
belongs_to :post
property :id, Serial
property :comment, Text
end
Then using the following route/code for some reason it throws an error because comments does not appear to be an attribute of user.
class MyApp < Sinatra::Application
get "/" do
@post = Post.get(1)
@post.comments.inspect
end
end
The tables DataMapper generate seem fine (using DataMapper.finalize & DataMapper.auto_upgrade!). It has a user table and a comment table that has a foreign key on posts.id.
Any advice on this?