Class: Integral::Backend::PostsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Integral::Backend::PostsController
- Defined in:
- app/controllers/integral/backend/posts_controller.rb
Overview
Post management
Instance Method Summary collapse
-
#activities ⇒ Object
GET /:id/activities.
-
#activity ⇒ Object
GET /:id/activities/:id.
-
#create ⇒ Object
POST / Post creation.
-
#destroy ⇒ Object
DELETE /:id.
-
#edit ⇒ Object
GET /:id/edit Post edit form.
-
#index ⇒ Object
GET / Lists all posts.
-
#new ⇒ Object
GET /new Post creation form.
-
#update ⇒ Object
PUT /:id Updating a post.
Instance Method Details
#activities ⇒ Object
GET /:id/activities
73 74 75 |
# File 'app/controllers/integral/backend/posts_controller.rb', line 73 def activities respond_with_activities(:edit_backend_post_url) end |
#activity ⇒ Object
GET /:id/activities/:id
78 79 80 81 82 83 84 85 |
# File 'app/controllers/integral/backend/posts_controller.rb', line 78 def activity Version I18n.t('integral.navigation.activity'), :activities_backend_post_url I18n.t('integral.actions.view') @activity = PostVersion.find(params[:activity_id]).decorate end |
#create ⇒ Object
POST / Post creation
35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/integral/backend/posts_controller.rb', line 35 def create @post = Post.new(post_params) @post.user = current_user if @post.save respond_successfully(('creation_success'), edit_backend_post_path(@post.id)) else respond_failure(('creation_failure'), @post, :new) end end |
#destroy ⇒ Object
DELETE /:id
63 64 65 66 67 68 69 70 |
# File 'app/controllers/integral/backend/posts_controller.rb', line 63 def destroy if @post.destroy respond_successfully(('delete_success'), backend_posts_path) else flash[:error] = ('delete_failure') redirect_to backend_posts_path end end |
#edit ⇒ Object
GET /:id/edit Post edit form
48 49 50 |
# File 'app/controllers/integral/backend/posts_controller.rb', line 48 def edit I18n.t('integral.navigation.edit'), :edit_backend_post_path end |
#index ⇒ Object
GET / Lists all posts
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/integral/backend/posts_controller.rb', line 9 def index respond_to do |format| format.html do set_grid(Integral::Grids::PostsGrid) end format.json do if params[:gridview].present? set_grid(Integral::Grids::PostsGrid) render json: { content: render_to_string(partial: 'integral/backend/posts/grid', locals: { grid: @grid }) } else respond_to_record_selector(Integral::Post) end end end end |
#new ⇒ Object
GET /new Post creation form
28 29 30 31 |
# File 'app/controllers/integral/backend/posts_controller.rb', line 28 def new I18n.t('integral.navigation.new'), :new_backend_post_path @post = Post.new end |
#update ⇒ Object
PUT /:id Updating a post
54 55 56 57 58 59 60 |
# File 'app/controllers/integral/backend/posts_controller.rb', line 54 def update if @post.update(post_params) respond_successfully(('edit_success'), edit_backend_post_path(@post.id)) else respond_failure(('edit_failure'), @post, :edit) end end |