Ask A Question

Notifications

You’re not receiving notifications from this thread.

Liking Posts in Rails with Hotwire Discussion

Really fun to revise our most popular GoRails episode on Liking Posts and update it for modern Rails. No more jQuery, js.erb responses, or any custom JavaScript! Just super clean and simple operations with Hotwire.

Reply

Hey Chris, Did you choose to use only the 'update' action to avoid issues with the 'destroy' action?

I used this video as inspiration and originally set it up the same way, more or less and later refactored to using 'create' and 'destroy' actions using the join_table controller. I also watched your 'turbo_frame' refactor video.

I am able to get the 'create' action to work with either turbo_streams or a turbo_frame and rendering the partial where the 'button_to' elements are but I have, so far, been unsuccessful at getting the turbo_stream to work with the 'destroy' action. If I use a turbo_frame, I can use a work-around on the 'destroy' action by using redirect_to the 'partial' instead of 'render'. It works but it is not as fast as the 'create' action with render.

The error I am getting when trying to click on the 'delete' button, is 'undefined method `to_key' for nil:NilClass.

Any suggestions?

Thanks! : )

Reply
Join the discussion
Create an account Log in

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

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

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