Class: RailsBloggerEngine::ArticlesController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /articles



27
28
29
30
31
32
33
34
35
# File 'app/controllers/rails_blogger_engine/articles_controller.rb', line 27

def create
  @article = Article.new(article_params)

  if @article.save
    redirect_to @article, notice: 'Article was successfully created.'
  else
    render :new
  end
end

#destroyObject

DELETE /articles/1



47
48
49
50
51
# File 'app/controllers/rails_blogger_engine/articles_controller.rb', line 47

def destroy
  @article = Article.find(params[:id])
  @article.destroy
  redirect_to articles_url, notice: 'Article was successfully destroyed.'
end

#editObject

GET /articles/1/edit



23
24
# File 'app/controllers/rails_blogger_engine/articles_controller.rb', line 23

def edit
end

#indexObject

GET /articles



8
9
10
# File 'app/controllers/rails_blogger_engine/articles_controller.rb', line 8

def index
  @articles = Article.all.order('created_at DESC')
end

#newObject

GET /articles/new



18
19
20
# File 'app/controllers/rails_blogger_engine/articles_controller.rb', line 18

def new
  @article = Article.new
end

#showObject

GET /articles/1



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

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

#updateObject

PATCH/PUT /articles/1



38
39
40
41
42
43
44
# File 'app/controllers/rails_blogger_engine/articles_controller.rb', line 38

def update
  if @article.update(article_params)
    redirect_to @article, notice: 'Article was successfully updated.'
  else
    render :edit
  end
end