Class: Admin::Page::ArticlesController
- Inherits:
-
BaseController
- Object
- BaseController
- Admin::Page::ArticlesController
- Defined in:
- app/controllers/admin/page/articles_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
29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/admin/page/articles_controller.rb', line 29 def create @article = @section.articles.build(params[:article]) if @article.save trigger_events(@article) redirect_to [:edit, :admin, @section, @article], notice: "The article has been created." else set_categories flash.now.alert = "The article could not be created." + current_resource_errors render :action => 'new' end end |
#destroy ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/admin/page/articles_controller.rb', line 54 def destroy if @article.destroy trigger_events(@article) redirect_to [:admin, @section, :contents], notice: "The article has been deleted." else set_categories flash.now.alert = "The article could not be deleted." + current_resource_errors render :action => 'edit' end end |
#edit ⇒ Object
26 27 |
# File 'app/controllers/admin/page/articles_controller.rb', line 26 def edit end |
#index ⇒ Object
12 13 14 |
# File 'app/controllers/admin/page/articles_controller.rb', line 12 def index redirect_to [:admin, @section, :contents] end |
#new ⇒ Object
21 22 23 24 |
# File 'app/controllers/admin/page/articles_controller.rb', line 21 def new defaults = { :comment_age => @section.comment_age, :filter => @section.content_filter } @article = @section.articles.build(defaults.update(params[:article] || {})) end |
#show ⇒ Object
16 17 18 19 |
# File 'app/controllers/admin/page/articles_controller.rb', line 16 def show @article.revert_to(params[:version]) if params[:version] render :template => "#{@section.type.tableize}/articles/show", :layout => 'default' end |
#update ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/admin/page/articles_controller.rb', line 41 def update @article.attributes = params[:article] if @article.save trigger_events(@article) redirect_to [:edit, :admin, @section, @article], notice: "The article has been updated." else set_categories flash.now.alert = "The article could not be updated." + current_resource_errors render :action => 'edit' end end |