This time I introduced Vue.js to the application under development with rails, so I will record it as a memorandum. I hope it helps people who use Vue.js with rails for the first time. Also, since it is a beginner, please point out any mistakes! ruby 2.6.5 Rails 6.0.3.3
If you have installed it, please skip it. Described in Gemgile
gem "webpacker", github: "rails/webpacker”
If you can write it, bundle install.
After installation, execute the following in the terminal
$ bin/rails webpacker:install
This completes the webpacker installation
Enter the following command in the terminal
$ rails webpacker:install:vue
Now you have created the files you need for Vue.js.
Describe the following in the application.html.erb file under app / views / layouts
<%= javascript_pack_tag "hello_vue" %>
When loaded normally, it will be displayed in the view as shown in the picture. https://gyazo.com/57e56686d2113920659f3dc9410f3a15
Now you can install Vue.js with rails! It's relatively easy to install, so please use it if you like! If you make a mistake, please teach me!
Recommended Posts