File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ layout : guides
3+ ---
4+ # Getting started - Hanami
5+
6+ In order to get a Hanami app rolling with jsonapi-rb, you will usually want to follow those 3 steps:
7+
8+ 1 . Add ` jsonapi-hanami ` to your ` Gemfile ` :
9+
10+ ``` ruby
11+ # Gemfile
12+
13+ gem ' jsonapi-hanami'
14+ ```
15+
16+ 2 . Declare the ` :jsonapi ` MIME type (for serialization):
17+
18+ ``` ruby
19+ # apps/foo/application.rb
20+
21+ module Foo
22+ class Application < Hanami ::Application
23+ configure do
24+ # ...
25+ controller.format jsonapi: ' application/vnd.api+json'
26+ # ...
27+ end
28+ end
29+ end
30+ ```
31+
32+ 3 . Enable the JSON body parser (for deserialization):
33+
34+ ``` ruby
35+ # apps/foo/application.rb
36+
37+ module Foo
38+ class Application < Hanami ::Application
39+ configure do
40+ # ...
41+ body_parsers :json
42+ # ...
43+ end
44+ end
45+ end
46+ ```
47+
48+ 4 . Optional: Add ` apps/foo/resources/ ` to the ` load_path ` :
49+
50+ ``` ruby
51+ # apps/foo/application.rb
52+
53+ module Foo
54+ class Application < Hanami ::Application
55+ configure do
56+ # ...
57+ load_paths << [
58+ # ...
59+ ' resources'
60+ ]
61+ # ...
62+ end
63+ end
64+ end
65+ ```
66+
67+ ## Examples
68+
69+ <%= partial 'peeks/hanami' %>
Original file line number Diff line number Diff line change 1+ ---
2+ layout : guides
3+ ---
4+ # Getting started - Plain ruby
5+
6+ Soon
7+
8+ ## Examples
9+
10+ <%= partial 'peeks/plain' %>
Original file line number Diff line number Diff line change 1+ ---
2+ layout : guides
3+ ---
4+ # Getting started - Ruby on Rails
5+
6+ Soon
7+
8+ ## Examples
9+
10+ <%= partial 'peeks/rails' %>
Original file line number Diff line number Diff line change 1+ ---
2+ layout : guides
3+ ---
4+ # Getting started - Sinatra
5+
6+ Soon
Original file line number Diff line number Diff line change 1313 < li class ="toc-group ">
1414 < a href ="/guides "> Introduction</ a >
1515 </ li >
16+ < li class ="toc-group ">
17+ Getting started
18+ < ul >
19+ < li > < a href ="/guides/getting_started/plain_ruby.html "> Plain ruby</ a > </ li >
20+ < li > < a href ="/guides/getting_started/sinatra.html "> Sinatra</ a > </ li >
21+ < li > < a href ="/guides/getting_started/hanami.html "> Hanami</ a > </ li >
22+ < li > < a href ="/guides/getting_started/rails.html "> Ruby on Rails</ a > </ li >
23+ </ ul >
24+ </ li >
1625 < li class ="toc-group ">
1726 < a href ="/guides/serialization "> Serialization</ a >
1827 < ul >
You can’t perform that action at this time.
0 commit comments