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

access controller instance variables in representers #761

Open
tamoyal opened this issue Oct 1, 2023 · 0 comments
Open

access controller instance variables in representers #761

tamoyal opened this issue Oct 1, 2023 · 0 comments

Comments

@tamoyal
Copy link

tamoyal commented Oct 1, 2023

I see in the documentation that we should be able to access instance variables in the rabl however it does not work for me.

def create_thing
   @stuff = {key: "value"}
    render json: Rabl.render(@thing, "thing")
end

In the representer, accessing @stuff does not work:

node(:stuff) do
   @stuff[:key]
end

Passing around locals due but I'm trying to access the Rails request context in my rabl representers. Any idea why this wouldn't work or am I misunderstanding the docs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant