Skip to content

Auto-serialization of ActiveRecord models #68

Open
@seanders

Description

@seanders

Hi there,

One nice feature of ActiveModelSerializer-based rendering is the implicit serialization of instances of ActiveRecord::Base. See: https://github.com/rails-api/active_model_serializers/blob/v0.10.6/docs/general/getting_started.md#rails-integration

Would there be any appetite or interest for this behavior with the inertia renderer?

For example, say we have this render at the end of a controller action:

class SomeController < ApplicationController
  def show
    @post = Post.find(params[:id])
    render(inertia: 'SomeComponent',
      props: { post: @post } # This would implicitly serialize using a corresponding serializer?
    )
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions