Skip to content

Commit 591cfe5

Browse files
committed
Add basic getting started guide for Hanami and placeholders for other frameworks
1 parent d7f1ccc commit 591cfe5

5 files changed

Lines changed: 104 additions & 0 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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' %>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
layout: guides
3+
---
4+
# Getting started - Plain ruby
5+
6+
Soon
7+
8+
## Examples
9+
10+
<%= partial 'peeks/plain' %>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
layout: guides
3+
---
4+
# Getting started - Ruby on Rails
5+
6+
Soon
7+
8+
## Examples
9+
10+
<%= partial 'peeks/rails' %>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
layout: guides
3+
---
4+
# Getting started - Sinatra
5+
6+
Soon

source/layouts/guides.erb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
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>

0 commit comments

Comments
 (0)