Skip to content

Commit 82c6053

Browse files
committed
Bump version
1 parent 284efd3 commit 82c6053

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

README.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
If you need to send some data to your js files and you don't want to do this with long way through views and parsing - use this force!
55

6-
Now with [Rabl](https://github.com/nesquena/rabl) support!
6+
Now with [Jbuilder](https://github.com/rails/jbuilder) and [Rabl](https://github.com/nesquena/rabl) support!
77

88
## An example of typical use
99

@@ -202,18 +202,54 @@ gon mapping method:
202202
gon.rabl 'path/to/rabl/file', :as => 'alias'
203203
```
204204
205+
## Usage with Jbuilder
206+
207+
Use gon with [Jbuilder](https://github.com/rails/jbuilder) as with [Rabl](https://guthub.com/nesquena/rabl):
208+
209+
Jbuilder works now only on Ruby 1.9+, so Gon support for Jbuilder works on 1.9+ only
210+
211+
1. Create Jbuilder template.
212+
213+
`app/views/posts/index.json.jbuilder`
214+
215+
``` jbuilder
216+
json.posts @posts, :id, :title, :body
217+
```
218+
219+
2. In your controller you should map this template to gon.
220+
221+
``` ruby
222+
def index
223+
# some controller logic
224+
@posts = Post.all
225+
226+
gon.jbuilder 'app/views/posts/index.json.jbuilder'
227+
# some controller logic
228+
end
229+
```
230+
In javascript file for view of this action write call to your variable:
231+
232+
``` js
233+
alert(gon.posts)
234+
alert(gon.posts[0])
235+
alert(gon.posts[0].post.body)
236+
```
237+
238+
P.s. If you didn't put include_gon tag in your html head area - it
239+
wouldn't work. You can read about this in common usage above.
240+
205241
## Installation
206242
207243
Puts this line into `Gemfile` then run `$ bundle`:
208244
209245
``` ruby
210-
gem 'gon', '2.0.3'
246+
gem 'gon', '2.0.4'
211247
```
212248
213249
Or if you are old-school Rails 2 developer put this into `config/environment.rb` and run `$ rake gems:install`:
214250
215251
``` ruby
216-
config.gem 'gon', :version => '2.0.3'
252+
config.gem 'gon', :version => '2.0.4'
217253
```
218254
219255
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.3'
2+
VERSION = '2.0.4'
33
end

0 commit comments

Comments
 (0)