Class: Rtcl::ArticlesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Rtcl::ArticlesController
- Includes:
- Pagy::Backend
- Defined in:
- app/controllers/rtcl/articles_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'app/controllers/rtcl/articles_controller.rb', line 30 def create @article = Article.new(article_params.merge(author: current_user)) if @article.save redirect_to @article else render :new end end |
#destroy ⇒ Object
47 48 49 50 |
# File 'app/controllers/rtcl/articles_controller.rb', line 47 def destroy @article.discard! redirect_to articles_path end |
#edit ⇒ Object
27 28 |
# File 'app/controllers/rtcl/articles_controller.rb', line 27 def edit end |
#index ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/rtcl/articles_controller.rb', line 8 def index if params[:tag] @paginator, @articles = pagy(Article.tagged_with(params[:tag]).accessible_by(current_ability).latest, items: 8) else @paginator, @articles = pagy(Article.kept.accessible_by(current_ability).latest, items: 8) end respond_to do |format| format.html format.rss { render :layout => false } end end |
#new ⇒ Object
23 24 25 |
# File 'app/controllers/rtcl/articles_controller.rb', line 23 def new @article = Article.new end |
#show ⇒ Object
20 21 |
# File 'app/controllers/rtcl/articles_controller.rb', line 20 def show end |
#update ⇒ Object
39 40 41 42 43 44 45 |
# File 'app/controllers/rtcl/articles_controller.rb', line 39 def update if @article.update(article_params) render :show else render :edit end end |