@@ -208,6 +208,15 @@ Use gon with [Jbuilder](https://github.com/rails/jbuilder) as with [Rabl](https:
208208
209209Jbuilder works now only on Ruby 1.9+, so Gon support for Jbuilder works on 1.9+ only
210210
211+ 0. Add jbuilder to your Gemfile (because of it depends on
212+ ActiveSuppurt ' ~ > 3.0 .0 ' )
213+
214+ `Gemfile`
215+
216+ ``` ruby
217+ gem ' jbuilder'
218+ ```
219+
211220 1. Create Jbuilder template.
212221
213222 `app/views/posts/index.json.jbuilder`
@@ -227,12 +236,29 @@ Jbuilder works now only on Ruby 1.9+, so Gon support for Jbuilder works on 1.9+
227236 # some controller logic
228237 end
229238 ```
239+
230240In javascript file for view of this action write call to your variable:
231241
242+ Now you can use partials in jbuilder:
243+
244+ `app/views/posts/index.json.jbuilder`
245+
246+ ``` jbuilder
247+ json.partial! ' app/ views/ posts/ _part .json.jbuilder' , :comments => @posts[0].comments
248+ ```
249+
250+ `app/views/posts/_part.json.jbuilder`
251+
252+ ``` jbuilder
253+ json.comments comments.map{ |it| ' comment# ' + it.id }
254+ ```
255+
232256``` js
233257alert (gon .posts )
234258alert (gon .posts [0 ])
235259alert (gon .posts [0 ].post .body )
260+ alert (gon .comments )
261+ alert (gon .comments [0 ])
236262```
237263
238264P.s. If you didn't put include_gon tag in your html head area - it
@@ -243,13 +269,13 @@ wouldn't work. You can read about this in common usage above.
243269Puts this line into ` Gemfile ` then run ` $ bundle ` :
244270
245271``` ruby
246- gem ' gon' , ' 2.0 .4 '
272+ gem ' gon' , ' 2.0.5 '
247273```
248274
249275Or if you are old-school Rails 2 developer put this into ` config/environment.rb ` and run ` $ rake gems:install ` :
250276
251277``` ruby
252- config.gem ' gon' , :version => ' 2.0 .4 '
278+ config.gem ' gon' , :version => ' 2.0.5 '
253279```
254280
255281Or manually install gon gem: ` $ gem install gon `
0 commit comments