In this page

    Middleman > Link fields

    Link fields

    Suppose our blog_post model has the following fields:

    • author: Single link referencing a user record;

    • related_posts: Multiple links referencing other blog_post records;

    In this case, will return the linked user record (or nil, if the relation is empty), and blog_post.related will return an array of blog_post records. # => "Mark Smith"
    blog_post.related.each do |related_post|
    related_post.title # => "Another post!"

    Use method chains to navigate deep across your records' relationships: # => "Tom Kepler"

    Reverse lookups

    You can easily find all the blog post for a specific author with this Ruby one-liner:

    peter = dato.find("1413") { |blog_post| == peter }
    We use cookies to enhance the user experience. Do you consent their use in accordance with our cookie policy?