Class: Spree::Admin::PostsController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Spree::Admin::PostsController
- Defined in:
- app/controllers/spree/admin/posts_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/spree/admin/posts_controller.rb', line 15 def create @post = Spree::Post.new(post_params) if @post.save flash[:notice] = "Post saved successfully" redirect_to admin_posts_path else flash[:alert] = "There was an error saving your post" redirect_to :back end end |
#destroy ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/spree/admin/posts_controller.rb', line 41 def destroy @post = Spree::Post.find(params[:id]) if @post.destroy flash[:notice] = "Post removed successfully" redirect_to admin_posts_path else flash[:alert] = "There was an error removing the post" redirect_to :back end end |
#edit ⇒ Object
26 27 28 |
# File 'app/controllers/spree/admin/posts_controller.rb', line 26 def edit @post = Spree::Post.find(params[:id]) end |
#index ⇒ Object
3 4 5 |
# File 'app/controllers/spree/admin/posts_controller.rb', line 3 def index @posts = Spree::Post.all end |
#new ⇒ Object
11 12 13 |
# File 'app/controllers/spree/admin/posts_controller.rb', line 11 def new @post = Spree::Post.new end |
#show ⇒ Object
7 8 9 |
# File 'app/controllers/spree/admin/posts_controller.rb', line 7 def show @post = Spree::Post.find(params[:id]) end |
#update ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/spree/admin/posts_controller.rb', line 30 def update @post = Spree::Post.find(params[:id]) if @post.update_attributes(post_params) flash[:notice] = "Post saved successfully" redirect_to admin_posts_path else flash[:alert] = "There was an error saving your post" redirect_to :back end end |