Class: ArticlesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/articles_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

#destroyObject



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

#editObject



20
21
22
# File 'app/controllers/articles_controller.rb', line 20

def edit
   @article = Article.find(params[:id])
end

#indexObject



33
34
35
# File 'app/controllers/articles_controller.rb', line 33

def index
  @articles = Article.all
end

#newObject



6
7
8
# File 'app/controllers/articles_controller.rb', line 6

def new
  @article = Article.new
end

#showObject



16
17
18
# File 'app/controllers/articles_controller.rb', line 16

def show
   @article = Article.find(params[:id])
end

#updateObject



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