New Discussion

Notifications

You’re not receiving notifications from this thread.

Rails Components From Scratch Discussion

14
General

Great episode Chris!

Super episode -- putting this to work right now.

Thanks Chris - loved the episode: very informative. Lovely dynamic refactoring work, too, imho

The refactoring part is half the fun. πŸ˜„

Thank you very much, Chris - I really enjoyed that episode

Glad you found it helpful!

Great episode Chris, super cool explanation how it works behind the scenes!

These are my favorite kinds of things to learn and teach. Learning behind the scenes really helps you become a better developer. πŸ’ͺ

This is great! I wonder how easy it would be to get unit tests setup to do this kind of thing:

button = Components::Button.new(text: "Click me")
result = button.render_in(view_context)
expect(result).to include("Click me")

Using RSpec, I could imagine creating "component" type tests where the view_context is available in them. I don't actually know how to make it available but i'd love to know how.

I guess you could write a view spec and do this:

render Button.new(to: "some-path")
expect(rendered).to include("href=\"some-path\"")

Yep, you would want to treat them as a view specs because that's what they are. view_context is an instance of ActionView::Base. πŸ‘

Great. That was a really useful video, thanks Chris!

Didn't know about the ... nor the !!@variable very nice 🀯

Cool epicode, let me think why I need gem ViewComponent, lol. Thanks, Chris.

With gem ViewComponent, how to make component render partial in it's self directory as action view?

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 88,697+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.