0

Suppose I have {{data}} AngularJS data, that I can evaluate through

<%= j "{{data}}" %>

How can I pass this data to some ruby method inside my view (for example some helper method) ?

<%= any_method({{data}}) %>doesn't work

1 Answer 1

1

With AngularJS being client-side and Ruby/Rails being server-side, any data you want Ruby/Rails to process will have to be sent to the server.

Rails generates the page sent to the client, so sending data from Rails -> AngularJS is pretty straightforward, but if you try going the other direction it'll just be Angular talking to itself.

Simplest solution is just to serialize the data and POST it (via AJAX) to the server, have it processed and then have the result sent back (if needed).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.