Class: MyPlugin::PostsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
# File 'app/controllers/my_plugin/posts_controller.rb', line 12

def create
  @post = Post.new(post_params)
  if @post.save
    redirect_to @post
  else
    render :new, status: :unprocessable_entity
  end
end

#indexObject



3
4
5
# File 'app/controllers/my_plugin/posts_controller.rb', line 3

def index
  @posts = Post.all
end

#newObject



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

def new
  @post = Post.new
end

#showObject



6
7
8
# File 'app/controllers/my_plugin/posts_controller.rb', line 6

def show
  @post = Post.find(params[:id])
end