Class: Bongo::ArticlesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Bongo::ArticlesController
- Defined in:
- app/controllers/bongo/articles_controller.rb
Direct Known Subclasses
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/bongo/articles_controller.rb', line 33 def create @article = Article.new(article_params) @article if @article.save redirect_to @article, notice: 'Article was successfully created.' else render :new end end |
#destroy ⇒ Object
54 55 56 57 58 |
# File 'app/controllers/bongo/articles_controller.rb', line 54 def destroy @article @article.destroy redirect_to articles_url, notice: 'Article was successfully destroyed.' end |
#edit ⇒ Object
29 30 31 |
# File 'app/controllers/bongo/articles_controller.rb', line 29 def edit @article end |
#index ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/bongo/articles_controller.rb', line 9 def index @articles = policy_scope(Article).published.order(publish_at: :desc) respond_to do |format| format.html format.rss do @articles = @articles.published.order(publish_at: :desc) render layout: false end end end |
#new ⇒ Object
24 25 26 27 |
# File 'app/controllers/bongo/articles_controller.rb', line 24 def new @article = Article.new @article end |
#show ⇒ Object
20 21 22 |
# File 'app/controllers/bongo/articles_controller.rb', line 20 def show @article end |
#update ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/bongo/articles_controller.rb', line 44 def update @article if @article.update(article_params) redirect_to @article, notice: 'Article was successfully updated.' else render :edit end end |