All threads / What is a elegant way for embedding vue component into rails view template
Ask A Question

Notifications

You’re not receiving notifications from this thread.

What is a elegant way for embedding vue component into rails view template

Aleksandar asked in Ruby

Hi,

I'm doing this way like as follow
in the "***.html.erb"

<div class="col-sm-12" data-behaviour="vue">
    <component-abc props-a="abc"></component-abc>
</div>

here I'm wondering if I should not vue component tag into the rails template or should I do this way?

<%= content_tag :div,
  id: "hello-vue",
  data: {
    message: "Hello!",
    name: "David"
  }.to_json do %>
<% end %> 

I'd be much appreciated if anyone share their experience or the better way to do this.
Thanks in advance for you

Join the discussion

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

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

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

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.