Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kuroda/vue-rails-form-builder-demo

An example of Rails app using vue-form-for gem
https://github.com/kuroda/vue-rails-form-builder-demo

rails vuejs webpack

Last synced: 8 days ago
JSON representation

An example of Rails app using vue-form-for gem

Awesome Lists containing this project

README

        

# vue-rails-form-builder-demo

This is a Rails demo application using these libraries:

* [vue-rails-form-builder](https://github.com/kuroda/vue-rails-form-builder) -
A custom Rails form builder for Vue.js
* [vue-data-scooper](https://github.com/kuroda/vue-data-scooper) -
A Vue.js plugin to initialize the Vue instance data from form elements
* [vue-remote-template](https://github.com/kuroda/vue-remote-template) -
A Vue.js mixin to fetch template via Ajax

This application illustrates how we can combine the _traditional_ form builder
with Vue.js components.

Look at carefully these files:

* `Gemfile`
* `package.json`
* `app/views/customers/edit.html.erb`
* `app/views/customers/new.html.erb`
* `app/views/customers/_fields.html.erb`
* `app/javascript/packs/customers/fields.js`

Especially, note that we use `vue_form_for` helper in stead of `form_for`:

```erb
<%= vue_form_for @customer, html: { id: "customer-form" } do |f| %>
<%= render "fields", f: f %>


<%= f.submit "Update" %>

<% end %>
```

Also observe how we _use_ the `vue-data-scooper` plugin:

```javascript
import Vue from 'vue/dist/vue.esm'
import VueDataScooper from "vue-data-scooper"

Vue.use(VueDataScooper)

document.addEventListener("DOMContentLoaded", () => {
new Vue({
el: "#customer-form"
})
})
```

## Installation

```bash
git clone https://github.com/kuroda/vue-rails-form-builder-demo.git
cd vue-rails-form-builder-demo
bundle
yarn
bin/rake db:setup
```

## Running in development mode

In one terminal:

```bash
bin/webpack-dev-server
```

In another terminal:

```bash
rails s
```