Skip to content

Undefined Conversion  #291

Open
Open
@kirqe

Description

@kirqe

What is the alternative of ctx[key] = value that was available in rubyracer?

In rubyracer, the following block would return hi 1

ctx = MiniRacer::Context.new
person = Person.first
ctx[:person] = person
ctx.eval("'hi' + person.id")

I have tried the following things:

ctx.attach("person", proc{ person })

[8] pry(#<...>)> ctx.eval("person")
=> #<MiniRacer::JavaScriptFunction:0x0000000123b1d220>

[9] pry(#<...>)> ctx.eval("person.name")
=> ""

[10] pry(#<...>)> ctx.eval("person.id")
=> nil

[11] pry(#<...>)> ctx.eval("person()")
=> "Undefined Conversion"

What is the correct way to do what I've described above with mini_racer?

Thank you!

edit
Not exactly what I need but this kinda works(not for relations though eg person().address)

ctx.attach("person", proc{person.serializable_hash})
ctx.eval("person().id")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions