Class: Blogy::PostsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/blogy/posts_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /posts



30
31
32
33
# File 'app/controllers/blogy/posts_controller.rb', line 30

def create
  @post = Post.create(post_params)
  respond_with @post, root: :'blogy/post'
end

#destroyObject

DELETE /posts/1



42
43
44
45
# File 'app/controllers/blogy/posts_controller.rb', line 42

def destroy
  @post.destroy
  respond_with @post, root: :'blogy/post'
end

#editObject

GET /posts/1/edit



25
26
27
# File 'app/controllers/blogy/posts_controller.rb', line 25

def edit
  respond_with @post, root: :'blogy/post'
end

#indexObject

GET /posts



8
9
10
11
# File 'app/controllers/blogy/posts_controller.rb', line 8

def index
  @posts = Post.joins(:translations).all
  respond_with @posts, root: :'blogy/posts'
end

#newObject

GET /posts/new



19
20
21
22
# File 'app/controllers/blogy/posts_controller.rb', line 19

def new
  @post = Post.new
  respond_with @post, root: :'blogy/post'
end

#showObject

GET /posts/1



14
15
16
# File 'app/controllers/blogy/posts_controller.rb', line 14

def show
  respond_with @post, root: :'blogy/post'
end

#updateObject

PATCH/PUT /posts/1



36
37
38
39
# File 'app/controllers/blogy/posts_controller.rb', line 36

def update
  @post.update(post_params)
  respond_with @post, root: :'blogy/post'
end