Skip to content

Allow passing relationships to new/create  #290

Closed
@mjc

Description

@mjc

Currently this does not work:

[1] pry(#<PostTest>)> post = Post.new(name: "foo", core_post_id: 1, searchable: true, relationships: {user: User.find(1).first})
=> #<Post:@attributes={"type"=>"posts", "name"=>"foo", "body"="bar"}>
[2] pry(#<PostTest>)> post.save
NoMethodError: undefined method `as_json_api' for #<Hash:0x00007fc2e3a04968>
Did you mean?  as_json
from /Users/mjc/.gem/ruby/2.6.0/gems/json_api_client-1.5.3/lib/json_api_client/resource.rb:500:in `relationships_for_serialization'

I tried fiddling with things but this seems to be the expected syntax. I also noticed that there are no tests for this functionality.

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