Ask A Question


You’re not receiving notifications from this thread.

Any way to reduce complexity passing JSON to Vue.js component?

Eduard Garcia asked in Rails

I'm trying to figure out a way to reduce the complexity of passing a JSON to a Vue.js component.
Currently I've got something like this placed on a model scope,

  scope :to_vue, -> (id) {where(team_id: id).order(position: :asc).to_json(
      only: [:id, :name, :position, :team_id], include: {
          postits: {
              include: [:user, comments: {
                  include: :actor

Anyone know a better way to create a Json format without all that amount of includes?

Thanks for your answers.

Join the discussion
Create an account Log in

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

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

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

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

    © 2023 GoRails, LLC. All rights reserved.