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

How to get Rails backend data ? like CSRF token or form URL etc ... #64

Closed
liyaodong opened this issue Aug 13, 2015 · 1 comment
Closed

Comments

@liyaodong
Copy link

If we don't have view help like react-rails gem, how to get backend data ? pass a window.xxx global javascript variable ? or send a Ajax to backend ? or just write into static jsx file ?

And another question, the page A need Login.jsx component , another page B need Admin.jsx, if all client code has been bundle into one file, how to identify different component on different pages ? or one pages component bundle into one file, include them in rails view like this

dev mode

<script src="http://localhost:8080/assets/<%= controller_name + '_' + action_name%>-bundle.self.js"></script>

What is the best practice, please give your opinions, Thank you all !

@justin808
Copy link
Member

Hi @liyaodong, the example uses this: https://github.com/rails/jquery-ujs and $.ajax. We also use on bundle for the client side application, and check if a div id is on a page, before rendering the react component. It's also possible to put global data on the page. I've often used the https://github.com/gazay/gon for doing that.

Let's take this discussion over to http://forum.railsonmaui.com/ if you wish to discuss this further.

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

2 participants