Skip to content

Commit fdff33b

Browse files
committed
Readme and version
1 parent 795dad6 commit fdff33b

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,15 @@ Use gon with [Jbuilder](https://github.com/rails/jbuilder) as with [Rabl](https:
208208
209209
Jbuilder 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+
230240
In 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
233257
alert(gon.posts)
234258
alert(gon.posts[0])
235259
alert(gon.posts[0].post.body)
260+
alert(gon.comments)
261+
alert(gon.comments[0])
236262
```
237263

238264
P.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.
243269
Puts this line into `Gemfile` then run `$ bundle`:
244270

245271
``` ruby
246-
gem 'gon', '2.0.4'
272+
gem 'gon', '2.0.5'
247273
```
248274

249275
Or 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

255281
Or manually install gon gem: `$ gem install gon`

lib/gon/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Gon
2-
VERSION = '2.0.4'
2+
VERSION = '2.0.5'
33
end

0 commit comments

Comments
 (0)