Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined Conversion #291

Open
kirqe opened this issue Aug 21, 2023 · 0 comments
Open

Undefined Conversion #291

kirqe opened this issue Aug 21, 2023 · 0 comments
Labels

Comments

@kirqe
Copy link

kirqe commented Aug 21, 2023

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")
@tisba tisba added the question label Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants