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
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/admin/page/articles_controller.rb', line 31 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, @site, @section, @article] else set_categories flash.now[:error] = t(:'adva.articles.flash.create.failure') render :action => 'new' end end |
#destroy ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/controllers/admin/page/articles_controller.rb', line 74 def destroy if @article.destroy trigger_events(@article) flash[:notice] = t(:'adva.articles.flash.destroy.success') redirect_to [:admin, @site, @section, :contents] else set_categories flash.now[:error] = t(:'adva.articles.flash.destroy.failure') render :action => 'edit' end end |
#edit ⇒ Object
28 29 |
# File 'app/controllers/admin/page/articles_controller.rb', line 28 def edit end |
#index ⇒ Object
14 15 16 |
# File 'app/controllers/admin/page/articles_controller.rb', line 14 def index redirect_to [:admin, @site, @section, :contents] end |
#new ⇒ Object
23 24 25 26 |
# File 'app/controllers/admin/page/articles_controller.rb', line 23 def new defaults = { :comment_age => @section.comment_age, :filter => @section.content_filter } @article = @section.articles.build(defaults.update(params[:article] || {})) end |
#rollback ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/admin/page/articles_controller.rb', line 62 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, @site, @section, @article] end |
#show ⇒ Object
18 19 20 21 |
# File 'app/controllers/admin/page/articles_controller.rb', line 18 def show @article.revert_to(params[:version]) if params[:version] render :template => "#{@section.type.tableize}/articles/show", :layout => 'default' end |
#update ⇒ Object
44 45 46 |
# File 'app/controllers/admin/page/articles_controller.rb', line 44 def update params[:article][:version].present? ? rollback : update_attributes end |
#update_attributes ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/admin/page/articles_controller.rb', line 48 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, @site, @section, @article] else set_categories flash.now[:error] = t(:'adva.articles.flash.update.failure') render :action => 'edit' end end |