Discussion about this post

User's avatar
Sahu's avatar

Hi. Thanks for your content. I've started working with View Components, and your information has helped me a lot.

I tried using the component helper you shared in your talks:

```

def component(name, *args, **kwargs, &block)

render("#{name}_component".classify.constantize.new(*args, **kwargs), &block)

end

```

But it gave me problems when I nest a VC into another. I found a solution I wanted to share with you because you greatly helped me:

```

def component(name, *args, **kwargs, &block)

"#{name}_component".classify.constantize.new(*args, **kwargs).render_in(self, &block)

end

```

This solution uses the view_context (self) to render the component

Thank you again.

Expand full comment
2 more comments...