You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Change to use the same JSON for the server side load and the client
side load of the comments.
* Reuse one jbuilder template for the list and single view of comments.
* Update the docs with how to do this.
Copy file name to clipboardExpand all lines: README.md
+50
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,7 @@ You can see this tutorial live here: [http://reactrails.com/](http://reactrails.
40
40
41
41
In no particular order:
42
42
43
+
- Example of using the [react_on_rails](https://github.com/shakacode/react_on_rails)
43
44
- Example of Rails 4.2 with ReactJs/Redux with Webpack and ES7.
44
45
- Enable development of a JS client independently from Rails using Webpack Hot Module Reload. You can see this by starting the app and visiting http://localhost:3000
45
46
- Easily enable use of npm modules with a Rails application.
@@ -257,6 +258,55 @@ npm install
257
258
cd client && npm run build:client && npm run build:server
258
259
```
259
260
261
+
# JBuilder Notes
262
+
There's a bunch of gotchas with using [Jbuilder](https://github.com/rails/jbuilder) to create the
263
+
string version of the props to be sent to the react_on_rails_gem:
264
+
265
+
See the notes in this the example code. The two critical things:
266
+
267
+
1. Use `render_to_string` to create string of JSON.
268
+
2. Be sure to call `respond_to` afterwards.
269
+
270
+
app/controllers/pages_controller.rb
271
+
272
+
```ruby
273
+
classPagesController < ApplicationController
274
+
defindex
275
+
# NOTE: this could be an alternate syntax if you wanted to pass comments as a variable to a partial
0 commit comments