Class: Bloggable::ArticlesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Bloggable::ArticlesController
- Defined in:
- app/controllers/bloggable/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
27 28 29 30 31 32 33 34 |
# File 'app/controllers/bloggable/articles_controller.rb', line 27 def create @article = Article.new(article_params.merge(bloggable_type: @bloggable.class.to_s, bloggable_id: @bloggable.id)) if @article.save redirect_to @article, notice: 'Article was successfully created.' else render :new end end |
#destroy ⇒ Object
44 45 46 47 |
# File 'app/controllers/bloggable/articles_controller.rb', line 44 def destroy @article.destroy redirect_to articles_url, notice: 'Article was successfully destroyed.' end |
#edit ⇒ Object
24 25 |
# File 'app/controllers/bloggable/articles_controller.rb', line 24 def edit end |
#index ⇒ Object
12 13 14 |
# File 'app/controllers/bloggable/articles_controller.rb', line 12 def index @articles = Article.all end |
#new ⇒ Object
19 20 21 22 |
# File 'app/controllers/bloggable/articles_controller.rb', line 19 def new @article = Article.new end |
#show ⇒ Object
16 17 |
# File 'app/controllers/bloggable/articles_controller.rb', line 16 def show end |
#update ⇒ Object
36 37 38 39 40 41 42 |
# File 'app/controllers/bloggable/articles_controller.rb', line 36 def update if @article.update(article_params) redirect_to @article, notice: 'Article was successfully updated.' else render :edit end end |