Class: MyPlugin::PostsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- MyPlugin::PostsController
- Defined in:
- app/controllers/my_plugin/posts_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
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 |
#index ⇒ Object
3 4 5 |
# File 'app/controllers/my_plugin/posts_controller.rb', line 3 def index @posts = Post.all end |
#new ⇒ Object
9 10 11 |
# File 'app/controllers/my_plugin/posts_controller.rb', line 9 def new @post = Post.new end |
#show ⇒ Object
6 7 8 |
# File 'app/controllers/my_plugin/posts_controller.rb', line 6 def show @post = Post.find(params[:id]) end |