Class: Admin::ArticlesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/bigmouth/admin/articles_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/bigmouth/admin/articles_controller.rb', line 25

def create
  @article = Article.new(article_params)
  @article.user_id = current_user.id

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

#destroyObject



44
45
46
47
# File 'app/controllers/bigmouth/admin/articles_controller.rb', line 44

def destroy
  @article.destroy
  redirect_to admin_articles_url, notice: 'Article was successfully destroyed.'
end

#editObject



22
23
# File 'app/controllers/bigmouth/admin/articles_controller.rb', line 22

def edit
end

#indexObject



11
12
13
# File 'app/controllers/bigmouth/admin/articles_controller.rb', line 11

def index
  @articles = Article.all
end

#newObject



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

def new
  @article = Article.new
end

#showObject



15
16
# File 'app/controllers/bigmouth/admin/articles_controller.rb', line 15

def show
end

#updateObject



36
37
38
39
40
41
42
# File 'app/controllers/bigmouth/admin/articles_controller.rb', line 36

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