Class: ArticlesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ArticlesController
- Defined in:
- lib/app/controllers/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
17 18 19 20 21 22 23 24 25 |
# File 'lib/app/controllers/articles_controller.rb', line 17 def create @article = Article.new(article_params) if @article.save redirect_to @article else render 'new' end end |
#destroy ⇒ Object
35 36 37 38 39 |
# File 'lib/app/controllers/articles_controller.rb', line 35 def destroy @article.destroy redirect_to articles_path, notice: "Article was successfully destroyed." end |
#edit ⇒ Object
14 15 |
# File 'lib/app/controllers/articles_controller.rb', line 14 def edit end |
#index ⇒ Object
3 4 5 |
# File 'lib/app/controllers/articles_controller.rb', line 3 def index @articles = Article.all.page params[:page] end |
#new ⇒ Object
10 11 12 |
# File 'lib/app/controllers/articles_controller.rb', line 10 def new @article = Article.new end |
#show ⇒ Object
7 8 |
# File 'lib/app/controllers/articles_controller.rb', line 7 def show end |
#update ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/app/controllers/articles_controller.rb', line 27 def update if @article.update(article_params) redirect_to @article else render 'edit' end end |