1

Current state

I have a website fully developed in Rails, using Rails views, classic Coffescript and SCSS. All my routes are declared on routes.rb.

What it's needed

Some of the pages developed have a lot of logic associated with, and it makes more sense to migrate it to a web app. The chosen web app was Vue.js.

The whole website (a very complex product) will be incrementally deployed (when the page using Vue.js is ready, the page on the Rails app should be 'replaced' by the new one). A major constraint is that the codebase is different. The Vue.js app will get information from the Rails app API.

Problems (help needed)

How can I set that some routes goes to the Rails app, and others go to the Vue.js app? (remember that are different codebases, different 'physical folders')

Thanks in advance.

2
  • You can use Vue.js for the frontend, but can you for the backend ? I'm not sure it's a very common choice for the backend. What do you mean 'it makes more sense to migrate it to a web app' ? Rails is already a framework for web apps. Commented Apr 13, 2017 at 15:54
  • The problem is that the codebases are different Graham. From one side, we've Rails app that uses the database and views. From the other side we've the Vue app that loads the information using the Rails app API. Commented Apr 13, 2017 at 16:05

1 Answer 1

2

Have you checked out the webpacker project?

If your vue project is already in single vue components, then you can import the component into rails projects.

To get started, please follow the readme of webpacker.

At your rails' view.

<%= javascript_pack_tag 'components/vue' %>

This way, you can continue to use rails' route.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the help and will get this answer as correct and upvote. I've used a server side proxy to manage this just to have total independence on my Vue app.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.