Class: ArticlesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ArticlesController
- Defined in:
- 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
10 11 12 13 14 |
# File 'app/controllers/articles_controller.rb', line 10 def create @article = Article.new(article_params) @article.save redirect_to @article end |
#destroy ⇒ Object
37 38 39 40 41 |
# File 'app/controllers/articles_controller.rb', line 37 def destroy @article = Article.find(params[:id]) @article.destroy redirect_to articles_path end |
#edit ⇒ Object
20 21 22 |
# File 'app/controllers/articles_controller.rb', line 20 def edit @article = Article.find(params[:id]) end |
#index ⇒ Object
33 34 35 |
# File 'app/controllers/articles_controller.rb', line 33 def index @articles = Article.all end |
#new ⇒ Object
6 7 8 |
# File 'app/controllers/articles_controller.rb', line 6 def new @article = Article.new end |
#show ⇒ Object
16 17 18 |
# File 'app/controllers/articles_controller.rb', line 16 def show @article = Article.find(params[:id]) end |
#update ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'app/controllers/articles_controller.rb', line 24 def update @article = Article.find(params[:id]) if @article.update(article_params) redirect_to @article else render 'edit' end end |