Class: ArticlesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

#destroyObject



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

#editObject



14
15
# File 'lib/app/controllers/articles_controller.rb', line 14

def edit
end

#indexObject



3
4
5
# File 'lib/app/controllers/articles_controller.rb', line 3

def index
  @articles = Article.all.page params[:page]
end

#newObject



10
11
12
# File 'lib/app/controllers/articles_controller.rb', line 10

def new
  @article = Article.new
end

#showObject



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

def show
end

#updateObject



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