Unitialized constant by rendering .rux from .html.erb template
Closed this issue · 6 comments
#app/components/ui/buttons/red_button_component/red_button_component.rux
class Ui::Buttons::RedButtonComponent::RedButtonComponent < ViewComponent::Base
def initialize
end
def call
<div>button</div>
end
end
<!--erb template in another simple view component (not rux) -->
<%= render Ui::Buttons::RedButtonComponent::RedButtonComponent.new(), layout: false %>
@camertron bump👆
Hey @serhiijun, thanks for reaching out about this. Unfortunately I haven't been able to reproduce it in my rux test app. It would help a great deal if you could put together your own test app that demonstrates the problem. It would also help if you could tell me:
- Your ruby version
- Your rails version
- If you're using Zeitwerk
- If the
RedButtonComponent
lives in a Rails engine
@camertron please check this demo repo https://github.com/serhiijun/rails_rux_demo
Uncomment this line, please, to reproduce an issue https://github.com/serhiijun/rails_rux_demo/blob/main/app/components/ui/bentries/home_component/home_component.html.erb#L3
Hey @serhiijun, thanks for the demo repo, that was really helpful! I see two issues at play here:
- It looks like your Gemfile contains the rux gem, but not rux-rails. All the logic that makes auto-compilation and hot reloading possible are in rux-rails, so you'll need to replace rux with rux-rails in your Gemfile.
- I just discovered that a recent update to Zeitwerk has caused a small bug in rux-rails versions 1.2.1 and earlier, so please make sure you use rux-rails 1.2.2, published about 5 minutes ago.
@camertron thank you a lot! Now that works, really cool!🎉 I'm sure this is a new way we need to code our rails components!
Awesome, glad it's working for you! 😄