New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with Stimulus Reflex and ViewComponent #284
Comments
That is indeed a weird one! I have essentially zero experience with ViewComponent, but I do have two things for you to try. First, if you load up a byebug breakpoint again and actually get it to return Second, could you try adding |
Okay it seems I found the problem, it really seems to be the monkey patched |
I'm glad you got sorted out, but is this something that could impact other people? If so, it would be nice if you could explain the problem and solution in more detail as about 50% of our users are ViewComponent users, too. |
So I'll try to explain it. In my application I use wicked_pdf to create pdf for orders the users create, so it can be printed out. Because both libraries (wicked_pdf aswell as ViewComponents) are monkey patching the So I went to the ViewComponents repository and found a rather hacky solution by replacing the It's described here Then the next problem popped up, for which I created this thread. You can't rerender a view component with the base My solution (until there's a better fix for it either from wicked_pdf or when Rails 6.1 comes out) was to create an initializer (I got the hint from this PR which is linked in the according issue over at wicked_pdf):
With this in place, you can use the "standard" Hope it helps somebody who maybe got the same problems :). |
@alliedarmour Thanks for doing this. Really appreciate it. |
I'm experiencing an issue which may be related to the coexistence with wicked pdf, but I'm not sure. In my reflex I want to re-render a view component with the morph directive, like so:
Then my view component is initialized with the user record like this:
I tried to pass the user instance directly aswell, but still same issue.
Now, in my view (cause of wicked pdf) I have to render the component with the render_component directive instead of just render.
Now, when I want to re-render just this table with the reflex above, I get the following error:
StimulusReflex::Channel Failed to invoke Order#order_success! http://localhost:3000/users/1/order_cards/new '#<MealComponent:0x000055fe47a95e98 @user=#<User id: 1, name: "Admin User", email: "example@braunfels.org", password_digest: "$2a$10$sx3fPbyQoPfIP4j/iIiGeOYbNw2laFIE.iVwzCxP7ts...", twoFactorEnabled: "enabled", canDoGuestOrder: true, commentedToday: true, hasCommentedThisWeek: true, otp_secret_key: "ZZOJYZGT6ENI2HADWXPELKVAGREEW2VS", created_at: "2020-07-18 11:36:03", updated_at: "2020-07-24 17:18:03", reset_digest: nil, reset_sent_at: nil, workplace_id: 2, has_ldap_connection: nil, salt: "zhxBMJfAmPVW4MiXvCu3", remember_me_token: "T1fgN4zhqdW17juCH6K4", remember_me_token_expires_at: "2020-08-06 07:51:43", user_accountable_type: "ExternalClinicAccount", user_accountable_id: 1>>' is not an ActiveModel-compatible object. It must implement :to_partial_path. /home/mkrs/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/actionview-6.0.3.2/lib/action_view/renderer/partial_renderer.rb:493:in
partial_path'`But as I checked inside the initialize method of the component, it IS implementing :to_partial_path:
Any idea what is happening here? If I just let the whole page reload it works cause it calls the controller action, but it doesn't work like this.
The text was updated successfully, but these errors were encountered: