I'm feeling stronger and stronger about how we're missing a tool or abstraction around passing data between the controller and the view. ActiveRecord::Relation doesn't cut it as the relationships get more complex, and data sources get more diverse (maybe more than one db!).

4
Share
Share on Mastodon
Share on Twitter
Share on Facebook
Share on Linkedin
Stephann V.

@nateberkopec I'm not sure you are talking about this, but I have been using ViewComponents to solve those missing contract issues. No more random `@variable` defined in before_action hook in some controller concern being acessed on view templates, you have to provide everything that view needs to be rendered

0
7mo
Justin 🌻

@nateberkopec the ‘view model’ vs ‘data model’ pattern (mvvm) seems to help when applied to apps (iOS etc) but does seem to either be forgotten or not work the same? So we end up with ‘services/presenter’ layer which is more about passing between the db and the controller.

0
7mo
Jamie Lawrence

@nateberkopec like Elixir’s repository pattern?

1
7mo
Irving Reid

@nateberkopec especially when preloading / n+1 query problems come into play. How to say “this interface structure is assembled from these parts” in a way that lets the framework figure out the efficient approach more of the time

0
7mo
Replies