Class: 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
- #rollback ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #update_attributes ⇒ Object
Instance Method Details
#create ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/admin/page/articles_controller.rb', line 29 def create @article = @section.articles.build(params[:article]) if @article.save trigger_events(@article) flash[:notice] = t(:'adva.articles.flash.create.success') redirect_to [:edit, :admin, @section, @article] else set_categories flash.now[:error] = t(:'adva.articles.flash.create.failure') + current_resource_errors render :action => 'new' end end |
#destroy ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/controllers/admin/page/articles_controller.rb', line 72 def destroy if @article.destroy trigger_events(@article) flash[:notice] = t(:'adva.articles.flash.destroy.success') redirect_to [:admin, @section, :contents] else set_categories flash.now[:error] = t(:'adva.articles.flash.destroy.failure') + 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 |
#rollback ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/admin/page/articles_controller.rb', line 60 def rollback version = params[:article][:version].to_i if @article.version != version and @article.revert_to(version) trigger_event(@article, :rolledback) flash[:notice] = t(:'adva.articles.flash.rollback.success', :version => version) else flash[:error] = t(:'adva.articles.flash.rollback.failure', :version => version) end redirect_to [:edit, :admin, @section, @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
42 43 44 |
# File 'app/controllers/admin/page/articles_controller.rb', line 42 def update params[:article][:version].present? ? rollback : update_attributes end |
#update_attributes ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/admin/page/articles_controller.rb', line 46 def update_attributes @article.attributes = params[:article] if @article.save trigger_events(@article) flash[:notice] = t(:'adva.articles.flash.update.success') redirect_to [:edit, :admin, @section, @article] else set_categories flash.now[:error] = t(:'adva.articles.flash.update.failure') + current_resource_errors render :action => 'edit' end end |