Modeling a task board

8 views
Skip to first unread message

Lucas Dohmen

unread,
Oct 30, 2018, 6:13:56 AM10/30/18
to Ohm Ruby
Hello :)

I'm new to this mailinglist and would love some advice on how to model a problem with Ohm :)

I'm trying to model a Taskboard with Ohm. In Ruby Code without persistence, it looks like this:

```
board = Board.new(
  title: "My Board",
    lanes: [
      Lane.new(
        title: "Backlog",
        cards: [ Card.new(title: "Lorem ipsum dolor sit amet"), ... ]
      ),
    ...
)
```

Now I want to persist this with Ohm. Both the lanes within a board as well as the cards within a lane have an order. So I thought about something like this:

```
class Board < Ohm::Model
  attribute :title
  list :lanes, :Lane
end

class Lane < Ohm::Model
  attribute :title
  list :cards, :Card
end

class Card < Ohm::Model
  attribute :title
end
```

This is basically a simple port of my Ruby Code to Ohm. But is that a good way to do it? I feel like querying for all cards on a board to display them will be quite cumbersome to query all cards for a board when I model it this way.

Any opinions or suggestions on that?

Best Wishes
Lucas

Michel Martens

unread,
Nov 1, 2018, 1:22:29 PM11/1/18
to ohm-...@googlegroups.com
Hey Lucas!

I think the design is good, that would be my approach as well :-)
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "Ohm Ruby" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ohm-ruby+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Lucas Dohmen

unread,
Nov 3, 2018, 3:49:15 AM11/3/18
to ohm-...@googlegroups.com
Hey :)

Thank you for your feedback :) I've tried it and it works really well :) Another question about that:
How would you find the lane (and board) for a given card? For an "unsorted" relationship, it would be:

```
class Card < Ohm::Model
reference :lane, :Lane
end

class Lane < Ohm::Model
collection :cards, :Card
end
```

But this won't work with a list. I could add a reference to the Card, but it won't synchronize with the
list in the Lane, so I need to do that by hand. Or is there a simpler way I'm missing?

Best Wishes
Lucas
signature.asc
Reply all
Reply to author
Forward
0 new messages