Class: ArticlesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ArticlesController
- Defined in:
- app/controllers/articles_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /articles.
-
#destroy ⇒ Object
DELETE /articles/1.
-
#edit ⇒ Object
GET /articles/1/edit.
-
#index ⇒ Object
GET /articles.
-
#new ⇒ Object
GET /articles/new.
-
#show ⇒ Object
GET /articles/1.
-
#update ⇒ Object
PATCH/PUT /articles/1.
Instance Method Details
#create ⇒ Object
POST /articles
23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/articles_controller.rb', line 23 def create @article = Article.new(article_params) if @article.save redirect_to @article, notice: "Article was successfully created." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
DELETE /articles/1
43 44 45 46 |
# File 'app/controllers/articles_controller.rb', line 43 def destroy @article.destroy! redirect_to articles_url, notice: "Article was successfully destroyed.", status: :see_other end |
#edit ⇒ Object
GET /articles/1/edit
19 20 |
# File 'app/controllers/articles_controller.rb', line 19 def edit end |
#index ⇒ Object
GET /articles
5 6 7 |
# File 'app/controllers/articles_controller.rb', line 5 def index @articles = Article.all end |
#new ⇒ Object
GET /articles/new
14 15 16 |
# File 'app/controllers/articles_controller.rb', line 14 def new @article = Article.new end |
#show ⇒ Object
GET /articles/1
10 11 |
# File 'app/controllers/articles_controller.rb', line 10 def show end |
#update ⇒ Object
PATCH/PUT /articles/1
34 35 36 37 38 39 40 |
# File 'app/controllers/articles_controller.rb', line 34 def update if @article.update(article_params) redirect_to @article, notice: "Article was successfully updated.", status: :see_other else render :edit, status: :unprocessable_entity end end |