camertron/rux

Unitialized constant by rendering .rux from .html.erb template

Closed this issue · 6 comments

image

#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 %>

image

@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:

  1. Your ruby version
  2. Your rails version
  3. If you're using Zeitwerk
  4. If the RedButtonComponent lives in a Rails engine

Hey @serhiijun, thanks for the demo repo, that was really helpful! I see two issues at play here:

  1. 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.
  2. 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! 😄