Live data from Hacker News

Rails 6.1

weblog.rubyonrails.org

21–30 of 87 posts

Re: Rails 6.1

#21
post #16

Earlier quoted context omitted.

Depending on your patience you can go and take a look at a real life implementation of it at https://app.hey.com since they enable source maps. What the actual developer facing API is going to look like however is another question. I do kind of worry that given how much is has been talked up by DHH in particular that it is going to struggle to live up to the hype. Either way, I am excited to see something new in the…

I was sold on hey.com's UI design already because it's using for dropdown menus. The really fun part, though: the summary content isn't just a menu icon, it's a trigger for some (currently unpublished) Turbolinks variant. The menu content is loaded (and subsequently 304'd) dynamically as a server-rendered partial (sans layout). Most tellingly, if you visit the menu content's XHR URL with regular browsing then hey.com…

Based on my casual browsing of the code I assume that it pushes small HTML fragments via WebSockets whenever the backend state changes on a given ActiveRecord model. It covers things like automatically updating the state of a model on a page, adding, removing, reordering elements etc all without any custom code so long as things are wired up correctly.

Basically, all the "re-activeness" of an SPA but without ever having to worry about the concept of client side state management at all.

Edit: I am a grumpy old man in web-dev years who hadn't ever really looked into Phoenix Live View before now but after watching a video on how it works, yes, my understanding is that it works basically the same way.

Re: Rails 6.1

#22
post #6

It's a really nice time to be a Ruby / Rails developer. Rails itself has made some really nice improvements with this release and there is also the "NEW MAGIC" should be following in the next couple of days which is currently being sold as what Rails was to the back end, this will be to the front end. Ruby 3 is also just a few days away which brings optional type checking to helps add some additional structure to lar…

Man I'm hoping NEW MAGIC is like Phoenix LiveView. As a Rails dev I started looking into the Elixir/Phoenix world just for LiveView but I don't really want to switch languages... I just want that new magic that LiveView offers. I know there are gems for Rails but I'd prefer if it was baked-in and officially supported.

LiveView is awesome - I'd be pleasantly surprised if Rails were able to pull off something that good with Ruby's more limited capacity for concurrency.

Re: Rails 6.1

#23
post #10

>Error Objects Active Model’s errors are now objects with an interface that allows your application to more easily handle and interact with errors thrown by models. The feature was implemented by lulalala and includes a query interface, enables more precise testing, and access to error details. This has been in the work since Rails 5.x and I believe Lulalala extracted it from his work on Gitlab. And it was lot of har…

Couple of changes here that would be directly useful in what I'm working on. Does boost my confidence - as a dev newer to Rails - that the rough spots I'm spotting are recognized by other folks as well. It also tells me I can be more proactive in proposing changes, or at least in addressing those rough spots.

Re: Rails 6.1

#24
post #6

It's a really nice time to be a Ruby / Rails developer. Rails itself has made some really nice improvements with this release and there is also the "NEW MAGIC" should be following in the next couple of days which is currently being sold as what Rails was to the back end, this will be to the front end. Ruby 3 is also just a few days away which brings optional type checking to helps add some additional structure to lar…

Man I'm hoping NEW MAGIC is like Phoenix LiveView. As a Rails dev I started looking into the Elixir/Phoenix world just for LiveView but I don't really want to switch languages... I just want that new magic that LiveView offers. I know there are gems for Rails but I'd prefer if it was baked-in and officially supported.

> I started looking into the Elixir/Phoenix world just for LiveView but I don't really want to switch languages...

Yes, you want to add languages! Join us...

Re: Rails 6.1

#25

Earlier quoted context omitted.

Man I'm hoping NEW MAGIC is like Phoenix LiveView. As a Rails dev I started looking into the Elixir/Phoenix world just for LiveView but I don't really want to switch languages... I just want that new magic that LiveView offers. I know there are gems for Rails but I'd prefer if it was baked-in and officially supported.

LiveView is awesome - I'd be pleasantly surprised if Rails were able to pull off something that good with Ruby's more limited capacity for concurrency.

[deleted]

Re: Rails 6.1

#26

Earlier quoted context omitted.

Does a "delegated type" work with preloading associations, ala "includes"? This remains a pain point with many polymorphic associations in Rails, but not sure how the new functionality handles if, if it does at all.

Based on this GitHub comment[0], it appears the answer is yes although it requires a little additional customization out of the box to prevent N+1 queries.. [0] https://github.com/rails/rails/pull/39341#issuecomment-72725...

In conjunction with Rails's "russian-doll" caching, N+1 queries are (or at least, can be) a good thing.

This sounds counterintuitive; but, in the common case of read-heavy services, N ≐ 0 after the first access. When something changes, subsequent views end up loading & rendering the one record that changed, instead of preloading an entire collection.

However, achieving this in practice requires some care in the nesting of view partials and records.

c.f. DHH in https://www.youtube.com/watch?v=ktZLpjCanvg&t=4m27s "N+1 is a feature"

Re: Rails 6.1

#27
post #4

Lots of good stuff in here, including much more support for using UUIDs as PKs. My favorite new feature is "delegated type" in ActiveRecord to offer a new way to map class hierarchies onto database tables. I wrote a blog post about it[0], but the actual PR is very readable as well[1]. [0] https://www.stevenbuccini.com/how-to-use-delegate-types-in-r... [1] https://github.com/rails/rails/pull/39341

> Lots of good stuff in here, including much more support for using UUIDs as PKs.

I missed this. Going through the changelogs the only thing I found is support case-insensitivity for pg UUID types. Is that what you meant?

I really think that not supporting UUID PKs is one of biggest issues with Rails. You can go around it and maybe even use a gem for it, but that's still a bit risky.

Re: Rails 6.1

#28
post #4

Lots of good stuff in here, including much more support for using UUIDs as PKs. My favorite new feature is "delegated type" in ActiveRecord to offer a new way to map class hierarchies onto database tables. I wrote a blog post about it[0], but the actual PR is very readable as well[1]. [0] https://www.stevenbuccini.com/how-to-use-delegate-types-in-r... [1] https://github.com/rails/rails/pull/39341

We implemented something like this on our own. We have child classes that inherit from an AR-backed parent, and on the parent we implement an instance method that transforms it (via #becomes) to the appropriate child based on the value of an attribute. The final piece is another attribute that stores a serialized object of child-specific attributes, and other methods that dynamically define attribute readers at boot time. It'll be nice to migrate to this new feature to free ourselves from the burden of that last piece in particular.

Re: Rails 6.1

#29
post #10

>Error Objects Active Model’s errors are now objects with an interface that allows your application to more easily handle and interact with errors thrown by models. The feature was implemented by lulalala and includes a query interface, enables more precise testing, and access to error details. This has been in the work since Rails 5.x and I believe Lulalala extracted it from his work on Gitlab. And it was lot of har…

I'm out of the loop. what is New Magic?

DHH mentioned "NEW MAGIC" when he released the Hey stack on twitter [1]:

> The HEY stack: - Vanilla Ruby on Rails on the backend, running on edge - Stimulus, Turbolinks, Trix + NEW MAGIC on the front end

There has been a lot of speculation since then on what New Magic is. It was supposed to release at the same time as hey.com but they decided to postpone it till later. Many people think/hope that it is something similar to Phoenix LiveView

1: https://twitter.com/dhh/status/1275901955995385856

Re: Rails 6.1

#30

Earlier quoted context omitted.

Man I'm hoping NEW MAGIC is like Phoenix LiveView. As a Rails dev I started looking into the Elixir/Phoenix world just for LiveView but I don't really want to switch languages... I just want that new magic that LiveView offers. I know there are gems for Rails but I'd prefer if it was baked-in and officially supported.

LiveView is awesome - I'd be pleasantly surprised if Rails were able to pull off something that good with Ruby's more limited capacity for concurrency.

Ruby 3 is putting a lot of emphasis on concurrency with the new (experimental) Ractor Actor model [1] and the Fiber Scheduler [2]. Concurrency in Ruby is getting a lot better.

1: https://github.com/ruby/ruby/blob/master/doc/ractor.md

2: https://bugs.ruby-lang.org/issues/16786

Post reply on HN