Class: Admin::ArticlesController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /cornerstone/admin/articles/



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

def create
  @article = Article.new(params[:article])
  if @article.save
    flash[:notice] = 'Article was successfully created.'
  else
    @categories = Category.articles
  end
  respond_with(:admin, @article)
end

#destroyObject

DELETE /cornerstone/admin/articles/:id



53
54
55
56
57
# File 'app/controllers/cornerstone/admin/articles_controller.rb', line 53

def destroy
  @article = Article.find(params[:id])
  flash[:notice] = 'Article was successfully destroyed.' if @article.destroy
  respond_with(:admin, @article, :location => admin_articles_path)
end

#editObject

GET /cornerstone/admin/articles/:id/edit



35
36
37
38
39
# File 'app/controllers/cornerstone/admin/articles_controller.rb', line 35

def edit
  @article = Article.find(params[:id])
  @categories = Category.articles
  respond_with(:admin, @article)
end

#indexObject



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

def index
  @articles = Article.all
  respond_with(:admin, @articles)
end

#newObject

GET /cornerstone/admin/articles/new



17
18
19
20
21
# File 'app/controllers/cornerstone/admin/articles_controller.rb', line 17

def new
  @article = Article.new
  @categories = Category.articles
  respond_with(:admin, @articles)
end

#showObject



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

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

#updateObject

PUT /cornerstone/admin/articles/:id



42
43
44
45
46
47
48
49
50
# File 'app/controllers/cornerstone/admin/articles_controller.rb', line 42

def update
  @article = Article.find(params[:id])
  if @article.update_attributes(params[:article])
    flash[:notice] = 'Article was successfully updated.'
  else
    @categories = Category.articles
  end
  respond_with(:admin, @article)
end