Class: Admin::PostsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::PostsController
- Defined in:
- app/controllers/admin/posts_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/admin/posts_controller.rb', line 33 def create @post = Post.new if @post.update_attributes( post_params ) flash[:notice] = "Post created successfully" else flash[:notice] = "Post failed to update" end respond_with( [:admin, @post] ) end |
#edit ⇒ Object
16 17 18 19 |
# File 'app/controllers/admin/posts_controller.rb', line 16 def edit @post = Post.find( params[:id] ) respond_with( @post ) end |
#index ⇒ Object
6 7 8 9 |
# File 'app/controllers/admin/posts_controller.rb', line 6 def index @posts = Post.all respond_with( @posts ) end |
#show ⇒ Object
11 12 13 14 |
# File 'app/controllers/admin/posts_controller.rb', line 11 def show @post = Post.find( params[:id] ) respond_with( @post ) end |
#update ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/admin/posts_controller.rb', line 21 def update @post = Post.find( params[:id] ) if @post.update_attributes( post_params ) flash[:notice] = "Post updated successfully" else flash[:notice] = "Post failed to update" end respond_with( [:admin, @post] ) end |